Refactor visible project users into query scope

This commit is contained in:
2026-04-21 00:08:12 +00:00
parent 740a20899c
commit f412e4ec19
3 changed files with 17 additions and 30 deletions
@@ -116,24 +116,10 @@ class BuildProjectTicketDetailPayload
'ticketTypes' => TicketTypeResource::collection($project->ticketTypes()->get())->resolve(),
'users' => UserResource::collection(
User::query()
->whereIn('id', $this->visibleUserIds($project))
->visibleToProject($project)
->orderBy('name')
->get(),
)->resolve(),
];
}
/**
* @return array<int, int>
*/
private function visibleUserIds(Project $project): array
{
return User::query()
->get()
->filter(fn (User $candidate): bool => $this->permissionService->allows($candidate, Permission::ProjectRead, $project))
->pluck('id')
->map(fn (mixed $userId): int => (int) $userId)
->values()
->all();
}
}