The typical method used to verify an authenticated user in Blade is:
@if (auth()->check()) // logic if user is authenticated @else // logic otherwise @endif
The code above shows how to verify authenticated users using the
auth()method returns the authenticated users in your application.
check()method is used to verify that the current user has been authenticated.
Although the above method is suitable for most purposes, a shorter way that Laravel offers is to use the
@endauth directives. This is shown below:
@auth // logic goes here @endauth
@auth directive determines if a user has been authenticated.
You can place any code snippet you want inside the
@endauth directives to run or display for a particular authenticated user. Since the
@endauth is like a closing tag for the
@auth directives, you can wrap the logic between the
endauth directives without needing to use the
View all Courses