PArticipationPolicy fix viewWonList pour recettage

This commit is contained in:
Jérémy Munsch 2023-12-20 16:11:05 +01:00
parent 2ef26bc270
commit d8ab0146e0
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -64,11 +64,15 @@ class ParticipationPolicy
/**
* Wether a customer can access to won list page
*
* @param \App\Models\Customer $authUser
* @param \App\Models\Customer|\App\Models\User $authUser
* @return boolean
*/
public function viewWonList(Customer $authUser): bool
public function viewWonList(Customer|User $authUser): bool
{
if ($authUser instanceof User) {
// * Recettage
return true;
}
return (bool)$authUser->participations()->where(fn (Builder $q) =>
$q->whereHas('instantWin')->orWhereHas('discount'))->count();
}