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:
parent
15c3073d66
commit
8a8ae44617
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue