getMessage(), $e); } return parent::render($request, $e); } /** * Convert an authentication exception into an unauthenticated response. * * @param Request $request */ protected function unauthenticated($request, AuthenticationException $exception): Response { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); } return redirect()->guest('login'); } }