Reverse query to get participations with the current code
This commit is contained in:
parent
4739b48a28
commit
532f294a77
1 changed files with 5 additions and 4 deletions
|
|
@ -161,10 +161,11 @@ class Code extends Model
|
|||
$settings = app(Settings::class);
|
||||
return Attribute::make(
|
||||
get: fn (): bool => $settings->nb_unique_code_use ?
|
||||
Participation::where(
|
||||
'code_unique_id',
|
||||
$this->id
|
||||
)->count() >= $settings->nb_unique_code_use : false
|
||||
Code::query()->where('id', $this->id)->whereHas(
|
||||
'participations',
|
||||
operator: '>=',
|
||||
count: $settings->nb_unique_code_use
|
||||
)->count() : false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue