app/Exceptions/Handler.php
/**
     * Convert an authentication exception into an unauthenticated response.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Illuminate\Auth\AuthenticationException $exception
     * @return \Illuminate\Http\Response
     */
Convert an authentication exception into an unauthenticated response.
Convert an authentication exception into an unauthenticated response .
protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['message' => 'Unauthenticated.'], 401);
        }
        return redirect()->guest(route('login'));
    }
protected function unauthenticated ( $ request , AuthenticationException $ exception ) { if ( $ request -> expectsJson ( ) ) { return response ( ) -> json ( [ 'message' => 'Unauthenticated.' ] , 401 ) ; } return redirect ( ) -> guest ( route ( 'login' ) ) ; }
Convert an authentication exception into an unauthenticated response.
Convert an authentication exception into an unauthenticated response .