donjan-deng/hyperf-permission

This package is abandoned and no longer maintained. The author suggests using the donjan-deng/hyperf-casbin package instead.

hyperf权限管理组件

2.0.0 2020-06-22 06:52 UTC

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);
                }
            }
        }