refactor(policy): optimize team membership checks in S3StoragePolicy

This commit is contained in:
Andras Bacsai 2025-07-03 15:52:26 +02:00
parent e3e80744a7
commit ea115e6d31

View file

@ -21,7 +21,7 @@ public function viewAny(User $user): bool
*/
public function view(User $user, S3Storage $storage): bool
{
return $user->teams()->get()->firstWhere('id', $storage->team_id) !== null;
return $user->teams()->where('id', $storage->team_id)->exists();
}
/**
@ -45,7 +45,7 @@ public function update(User $user, Server $server): bool
*/
public function delete(User $user, S3Storage $storage): bool
{
return $user->teams()->get()->firstWhere('id', $storage->team_id) !== null;
return $user->teams()->where('id', $storage->team_id)->exists();
}
/**