Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php laravel blade file Auth::check is not working

Tags:

php

laravel

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?

like image 327
Balaguru Murugan Avatar asked Feb 19 '16 09:02

Balaguru Murugan


People also ask

How do you call Auth in blade Laravel?

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!

How do you use Auth in Blade file?

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.

What does Auth :: check () do?

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.


1 Answers

Try use: auth()->check(), \Auth::check(), or remove all views in /var/www/html/laravel-master/storage/framework/views/.

like image 132
rome 웃 Avatar answered Oct 05 '22 23:10

rome 웃