If an entry is flagged as a no show at the time of the draw, put them at the end.

This commit is contained in:
Matt Young 2024-11-05 07:12:19 -06:00
parent 15c3073d66
commit 8a8ae44617
1 changed files with 9 additions and 0 deletions

View File

@ -21,6 +21,15 @@ class DrawService
DB::table('entries')->where('audition_id', $audition->id)->update(['draw_number' => null]);
$randomizedEntries = $audition->entries->shuffle();
// Move entries flagged as no show to the end
[$noShowEntries, $otherEntries] = $randomizedEntries->partition(function ($entry) {
return $entry->hasFlag('no_show');
});
// Merge the entries, placing the 'no_show' entries at the end
$randomizedEntries = $otherEntries->merge($noShowEntries);
foreach ($randomizedEntries as $index => $entry) {
$entry->draw_number = $index + 1;
$entry->save();