Laravel 5.2 Auth :: check()在异常页面(布局)上 [英] Laravel 5.2 Auth::check() on exception pages (layouts)
问题描述
当我中止(404)时,Laravel 5.2返回错误页面.但是,当我通过dump()方法调用Auth :: user()的Auth :: check()时,它会返回null.
但是我想在屏幕上显示当前登录用户的自定义错误页面(例如,我想要在菜单中的layouts/app.blade.php中:Goodmorning username ). /p>
我试图在app/exceptions/handler.php上启用Web中间件,但这没用.
有建议吗?
您可以添加自定义错误消息:
abort(404, 'ow noo, error 404'.Auth::user()->id);
在错误页面上:
{{ $exception->getMessage() }}
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?
You could add custom error message:
abort(404, 'ow noo, error 404'.Auth::user()->id);
And in the error page:
{{ $exception->getMessage() }}
这篇关于Laravel 5.2 Auth :: check()在异常页面(布局)上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!