shannon / permission
permission management
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:HTML
Type:project
This package is auto-updated.
Last update: 2025-03-15 23:07:12 UTC
README
使用教程
1、安装扩展
composer require zizaco/entrust
2、使用步骤
<1>、在config/app.php的providers数组添加一项:Zizaco\Entrust\EntrustServiceProvider::class,alias也添加一项;'Entrust' => Zizaco\Entrust\EntrustFacade::class,
<2>、在config/auth.php的providers的users添加一项:'table' => 'bas_user'
<3>、在app\Http\Kernel.php的$routeMiddleware添加3项:
'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
<4>、将app下的3个php文件复制到项目的app文件夹下,如果此文件夹下已有User.php,则添加两个属性即可:use EntrustUserTrait;protected $table = 'bas_user';table是用户数据表。
<6>app\Http\Controllers/PermissionController复制到项目的Controllers下,
如果没有改动过Controller.php,则可以直接覆盖掉;
若改动过Controller.php,则添加checkPermission()和getUserId()方法并在构造函数添加$this->checkPermission();
并且添加protected $userId = null;protected $user;两个属性
<7>、routes/permission.php复制到项目路由文件夹routes,并在web.php添加require_once 'permission.php';
<8>、app\Http\Services/PermissionService.php复制到项目app\Http\Services文件夹下(没有则创建)
<9>、将views下面的所有文件复制到项目的resource/views下