[英]Laravel Voyager: only see a menu item if the user is admin
我正在使用 Voyager,我想解決,如果用戶是管理員,請在歡迎頁面中再看到一個菜單項。
提前感謝您的回答!
<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>
您可以在視圖中檢查經過身份驗證的用戶的角色。 也許是這樣的:
@if (Auth::user()->hasRole('admin'))
<a href="...">This can only be seen by admins</a>
@endif
您可以從控制面板輕松執行此操作 轉到相應的角色並刪除該模型的權限,它將從該用戶的菜單中刪除 例如:如果您想從菜單中隱藏 Media特定角色或每個角色,轉到該角色並取消選中“瀏覽媒體”。
訪問航海者學院角色許可了解更多信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.