Laravel 5.2 Auth::check() on exception pages (layouts)

亡梦爱人 提交于 2019-12-24 03:02:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!