问题
When I abort(404) Laravel 5.2 returns an error page. But when I call Auth::check() of Auth::user() through the dump() method it return null.
But I want a custom error page with the current logged-in user on the screen (for example in the layouts/app.blade.php I want in the menu: Goodmorning username).
I tried to enable the web middleware on the app/exceptions/handler.php but that didn't work.
Anny suggestions?
回答1:
You could add custom error message:
abort(404, 'ow noo, error 404'.Auth::user()->id);
And in the error page:
{{ $exception->getMessage() }}
来源:https://stackoverflow.com/questions/36834149/laravel-5-2-authcheck-on-exception-pages-layouts