补充权限代码块儿注释说明
This commit is contained in:
@@ -23,12 +23,16 @@ class PermLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
$all = collect();
|
$all = collect();
|
||||||
|
// 遍历用户的所有角色,合并每个角色所拥有的资源
|
||||||
// 合并角色资源,排除不需要权限认证的资源
|
|
||||||
foreach ($user->roles as $role) {
|
foreach ($user->roles as $role) {
|
||||||
$all = $all->merge(
|
$all = $all->merge(
|
||||||
|
// 过滤当前角色的资源列表
|
||||||
$role->resources->filter(function ($resource) use($system) {
|
$role->resources->filter(function ($resource) use($system) {
|
||||||
// 只保留需要权限认证的资源(或公共资源)
|
// 资源过滤条件:
|
||||||
|
// 1. !$resource->no_auth:资源需要权限认证(排除公共资源)
|
||||||
|
// 2. 系统匹配条件:
|
||||||
|
// - $system->id == $resource->system_id:资源属于当前系统
|
||||||
|
// - $resource->system_id == 0:资源为全局公共资源(所有系统可用)
|
||||||
return !$resource->no_auth && ($system->id == $resource->system_id || $resource->system_id == 0);
|
return !$resource->no_auth && ($system->id == $resource->system_id || $resource->system_id == 0);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user