Reputation: 49
How to use in one Laravel blade view, information for guests that are not logged in and also for users that are Auth to appear the same stuff but also some other auth commands? Any example in that can be used in controllers and in view would be highly appreciated.
I assume that middleware will stop users to access page if they are not logged in, so i think there is another method.
Upvotes: 0
Views: 310
Reputation: 1325
Blade has some authentication directives to help with this. They check the authentication status and conditionally render the contained markup.
for example,
@auth('admin')
<a href="admin-only-link">Link</a>
@endauth
They are documented here: https://laravel.com/docs/master/blade#authentication-directives
Upvotes: 1