public function login(LoginRequest $request, JWTAuth $JWTAuth) { $credentials = $request->only(['email', 'password']); try { $token = $JWTAuth->attempt($credentials); if (!$token) { throw new AccessDeniedHttpException(); } } catch (JWTException $e) { throw new HttpException(500); } return response()->json(['status' => 'ok', 'token' => $token]); }