userRepository->getFirstWhere('email', $request->email); if (!$user || !$this->hash->check($request->password, $user->password)) { abort(Response::HTTP_UNAUTHORIZED, 'Invalid credentials'); } return response()->json([ 'token' => $this->tokenManager->createToken($user)->plainTextToken, ]); } public function logout() { if ($this->user) { $this->tokenManager->destroyTokens($this->user); } return response()->noContent(); } }