laravel权限控制Gate

  • 实现思想

注册

位置: app/Providers/AuthServiceProvider.php

$permissions    = \App\AdminPermission::all();
foreach ($permissions as $permission){
    Gate::define($permission->name,function ($user) use($permission){
        return $user->hasPermission($permission);
    });
}

 路由

Route::group(['middleware'=>'can:systems'],function(){});

页面模版

 

posted on 2018-12-25 18:00  爱吃柠檬不加糖  阅读(782)  评论(0编辑  收藏  举报

导航