bound('view')) { app()->register(\App\Providers\ViewServiceProvider::class); app()->register(\Illuminate\Translation\TranslationServiceProvider::class); } } catch (\Exception $e) { // continue without view } // try to upgrade generic exceptions to more specific ones foreach ($this->upgradable as $class) { if ($new = $class::upgrade($exception)) { return parent::render($request, $new); } } return parent::render($request, $exception); } /** * @param array $convert * @return Handler */ public function setConvert(array $convert): Handler { $this->convert = $convert; return $this; } /** * Convert an authentication exception into an unauthenticated response. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) { return $request->expectsJson() || $request->is('api/*') ? response()->json(['message' => $exception->getMessage()], 401) : redirect()->guest($exception->redirectTo() ?? route('login')); } }