Reputation: 23
I'm using Voyager, and I would like to solve, if the user is admin, see one more menu item in the welcome page.
Thank you in advance for the answers!
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
<a href="{{ route('register') }}">Register</a>
@endauth
</div>
@endif
<div class="content">
<div class="title m-b-md">
Laravel
</div>
<div class="links">
<a href="https://laravel.com/docs">Documentation</a>
<a href="https://laracasts.com">Laracasts</a>
<a href="https://laravel-news.com">News</a>
<a href="https://forge.laravel.com">Forge</a>
<a href="https://github.com/laravel/laravel">GitHub</a>
</div>
</div>
</div>
</body>
Upvotes: 1
Views: 7108
Reputation: 435
visit Voyager Academy Roles Permisson for more information
Upvotes: 0
Reputation: 106
You can do this easily from the control pannel Go to the corresponding role(s) and remove the permission for that model, and it will be removed from the menu for that user For example: if you want to hide Media from the menu for a perticular role or every role, go to that role and uncheck "Browse media".
Upvotes: 0
Reputation: 7194
You can check for the role of the authenticated user inside your view. Maybe something like this:
@if (Auth::user()->hasRole('admin'))
<a href="...">This can only be seen by admins</a>
@endif
Upvotes: 8