$map ['can_update' => 'module.entity.update', ...] * @param User|null $user 현재 사용자 * @return array 능력 불리언 맵 */ protected function resolveAbilitiesFromMap(array $map, ?User $user): array { if (empty($map)) { return []; } return collect($map) ->mapWithKeys(function (string $identifier, string $key) use ($user) { $hasPermission = PermissionHelper::check($identifier, $user); // 권한이 없으면 스코프 체크 불필요 if (! $hasPermission) { return [$key => false]; } // 리소스 모델이 있으면 스코프 접근 체크 // JsonResource 이중 래핑 시 내부 모델까지 추출 $resource = $this->resource; while ($resource instanceof \Illuminate\Http\Resources\Json\JsonResource) { $resource = $resource->resource; } if ($resource instanceof \Illuminate\Database\Eloquent\Model) { return [$key => PermissionHelper::checkScopeAccess($resource, $identifier, $user)]; } return [$key => true]; }) ->toArray(); } }