There are some blade directives such as @can and @cannot depending on how you've setup the roles and permissions.
https://laravel.com/docs/9.x/authorization#via-blade-templates
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I am new to Laravel. I have a Laravel web app (SchoolApp) registered on the Azure AD (App registrations). I have 3 user roles: Admin, Teacher, and student. I need to restrict some nav menus base on the user role. How can I do that? Can somebody guide me in the correct code? please?
Code: restrict for Teacher and student
@if(isset($userName))
<li class="nav-item" data-turbolinks="false">
<a class="navbar-brand d-flex align-items-center" href="{<!-- -->{ url('/registration_view') }}">
{<!-- -->{ __(' User registration ') }}
</a>
</li>
Code: restrict for student
@if(isset($userName))
<li class="nav-item" data-turbolinks="false">
<a class="navbar-brand d-flex align-items-center" href="{<!-- -->{ url('/Report_view') }}">
{<!-- -->{ __(' student Report ') }}
</a>
</li>
Please or to participate in this conversation.