Home / Snippets / Laravel Blade @auth Example
Laravel Blade @auth Example cover

Laravel Blade @auth Example

1.1K

3 years ago

0 comments

It's very common to check whether a user is authenticated in Laravel by using the "@if" blade directive. But instead of writing the logic which is quite long, you can easily make use of the "@auth" to replace it.

The common way using "@if" blade directive.
@if (auth()->user())
    // the user is authenticated
@endif

When using "@auth" blade directive.
@auth
    // the user is authenticated
@endauth
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this