[英]Laravel Voyager: only see a menu item if the user is admin
I'm using Voyager, and I would like to solve, if the user is admin, see one more menu item in the welcome page.我正在使用 Voyager,我想解决,如果用户是管理员,请在欢迎页面中再看到一个菜单项。
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>
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
您可以从控制面板轻松执行此操作 转到相应的角色并删除该模型的权限,它将从该用户的菜单中删除 例如:如果您想从菜单中隐藏 Media特定角色或每个角色,转到该角色并取消选中“浏览媒体”。
visit Voyager Academy Roles Permisson for more information访问航海者学院角色许可了解更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.