Skip to content

Laravel 5.5 – New Blade Directives , @auth and @guest

Last updated on February 17, 2018

As part of Laravel 5.5 version release, Laravel introduced new blade directives called @auth and @guest.As the name implies both can be useful to determine if the current user is authenticated or guest.

In the previous versions of Laravel to check user authentication status we’d used @if directive with the combination of Auth()->check(). But the new directives makes code lot cleaner, lets see how we can use them.

@auth and @guest

Now we can quickly check if the current user is authenticated or is a guest:

// usign @guest
@guest
  guest stuff here
@else
  logged user stuff here
@endauth

// using @auth
@auth
  logged user stuff here
@else
  guest stuff here
@endauth

old way of auth status check

@if (auth()->check()) 
@endif
0 0 votes
Article Rating
Subscribe
Notify of
guest

3 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments