mogody/hyperf-permission

hyperf权限管理组件

2.0.1 2022-04-10 05:04 UTC

This package is auto-updated.

Last update: 2022-06-10 05:38:21 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);
                }
            }
        }