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:

old way of auth status 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.

Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.


DMCA.com Protection Status