I am using Auth::check
function in laravel. In all controller its working fine but in blade file it will not working.
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
My blade file auth check code is
@if(Auth::check())
<div class="dispayingTextDiv"></div>
@endif
What is wrong?
Just run php artisan make:auth and php artisan migrate in a fresh Laravel application. Then, navigate your browser to http://your-app.test/register or any other URL that is assigned to your application. These two commands will take care of scaffolding your entire authentication system!
You can call the Auth facade in your views. $userInfo = User::find(Auth::id())->with('personalInfo')->first(); return View::make('page')->with('userInfo',$userInfo); //in your view then you have access to {{$userInfo->name }} {{$userInfo->address}} //the values from the table and related model.
Auth::check() defers to Auth::user() . It's been that way since as long as I can remember. In other words, Auth::check() calls Auth::user() , gets the result from it, and then checks to see if the user exists. The main difference is that it checks if the user is null for you so that you get a boolean value.
Try use: auth()->check()
, \Auth::check()
, or remove all views in /var/www/html/laravel-master/storage/framework/views/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With