Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

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

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 stuff here
  logged user stuff here

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

old way of auth status check

@if (auth()->check()) 

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of

Most Voted
Newest Oldest
Inline Feedbacks
View all comments