4
votes

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?

6
Syntaxt error. There is no ')' after Auth::check().izupet
Sorry i edited please seen my code again. My error is trueBalaguru Murugan

6 Answers

7
votes

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

2
votes

If Auth::check() does not work, use Illuminate\Support\Facades\Auth::check() instead:

@if(Illuminate\Support\Facades\Auth::check())
    <div class="dispayingTextDiv"></div>
@endif
2
votes

Auth :-

You can check as follows (5.5+)

@auth
  //your code 
@endauth 
2
votes

For unauthenticated you can use

@guest
// Show case unauthenticated
@endguest
0
votes

You can use blade directives take a look

@auth
// The user is authenticated...
@endauth
0
votes

Try this method

@guest
    // Show content if  unauthenticated
@endguest

@auth
    // The data only available for auth user
@endauth