donjan-deng / hyperf-permission
hyperf权限管理组件
Installs: 18 296
Dependents: 1
Suggesters: 0
Security: 0
Stars: 50
Watchers: 3
Forks: 10
Open Issues: 3
Requires
- php: ^7.2
- ext-swoole: >=4.5
- hyperf/cache: ~2.0
- hyperf/database: ~2.0
- hyperf/db-connection: ~2.0
- hyperf/utils: ~2.0
- hyperf/validation: ~2.0
Requires (Dev)
- hyperf/testing: ~2.0
This package is auto-updated.
Last update: 2021-08-02 07:29:34 UTC
README
https://github.com/donjan-deng/hyperf-casbin
转换至Casbin示例代码,按自己实际情况修改:
$roles = Role::with(['users', 'perms'])->get();
foreach ($roles as $role) {
if ($role->perms) {
foreach ($role->perms as $perm) {
Enforcer::addPermissionForUser($role->name, $perm->name, 'ANY');
}
}
if ($role->users) {
foreach ($role->users as $user) {
Enforcer::addRoleForUser($user->username, $role->name);
}
}
}