diff --git a/app/Services/DrawService.php b/app/Services/DrawService.php index 53d162c..f604d39 100644 --- a/app/Services/DrawService.php +++ b/app/Services/DrawService.php @@ -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();