php laravel 刀片文件 Auth::check 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35501354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php laravel blade file Auth::check is not working
提问by Balaguru Murugan
I am using Auth::check
function in laravel. In all controller its working fine but in blade file it will not working.
我Auth::check
在 Laravel 中使用函数。在所有控制器中它工作正常,但在刀片文件中它不起作用。
I got this error
我收到这个错误
Whoops, looks like something went wrong.
1/1 FatalErrorException in /var/www/html/laravel-master/storage/framework/views/e016f9336e75e5cb0b189c91cd736729b7184a61.php line 5: Call to undefined method Illuminate\Auth\AuthManager::check() in e016f9336e75e5cb0b189c91cd736729b7184a61.php line 5
哎呀,看起来出事了。
1/1 FatalErrorException in /var/www/html/laravel-master/storage/framework/views/e016f9336e75e5cb0b189c91cd736729b7184a61.php 第 5 行:调用未定义的方法 Illuminate\Auth\AuthManager::67c861b7c87b7c87b18c7b7c87b18c8c7b7e6c7b7e6c7b18c8c95cb18c95cb0b189d
My blade file auth check code is
我的刀片文件身份验证检查代码是
@if(Auth::check())
<div class="dispayingTextDiv"></div>
@endif
What is wrong?
怎么了?
回答by rome ?
Try use: auth()->check()
, \Auth::check()
, or remove all views in /var/www/html/laravel-master/storage/framework/views/
.
尝试使用: auth()->check()
, \Auth::check()
, 或删除/var/www/html/laravel-master/storage/framework/views/
.
回答by Sky
If Auth::check()
does not work, use Illuminate\Support\Facades\Auth::check()
instead:
如果Auth::check()
不起作用,请Illuminate\Support\Facades\Auth::check()
改用:
@if(Illuminate\Support\Facades\Auth::check())
<div class="dispayingTextDiv"></div>
@endif
回答by Arshid KV
Auth :-
验证:-
You can check as follows (5.5+)
您可以检查如下(5.5+)
@auth
//your code
@endauth
回答by Pablo Papalardo
For unauthenticated you can use
对于未经身份验证,您可以使用
@guest
// Show case unauthenticated
@endguest