mogody / hyperf-permission
hyperf权限管理组件
3.1.3
2024-09-30 03:15 UTC
Requires
- php: >=8.1
- ext-swoole: >=5.0
- hyperf/cache: ~3.1.0
- hyperf/command: ^3.1
- hyperf/database: ~3.1.0
- hyperf/db-connection: ~3.1.0
- hyperf/utils: ~3.1.0
- hyperf/validation: ~3.1.0
Requires (Dev)
- hyperf/testing: ~3.1.0
This package is auto-updated.
Last update: 2025-03-29 01:03:48 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);
}
}
}