补充权限代码块儿注释说明

This commit is contained in:
2025-08-14 11:06:54 +08:00
parent 311e407601
commit 962f891898
+7 -3
View File
@@ -23,12 +23,16 @@ class PermLogic
}
$all = collect();
// 合并角色资源,排除不需要权限认证的资源
// 遍历用户的所有角色,合并每个角色所拥有的资源
foreach ($user->roles as $role) {
$all = $all->merge(
// 过滤当前角色的资源列表
$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);
})
);