diff --git a/app/Http/Controllers/Tabulation/SeatAuditionFormController.php b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php index 1a0e8a1..8eb9f0b 100644 --- a/app/Http/Controllers/Tabulation/SeatAuditionFormController.php +++ b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php @@ -11,6 +11,7 @@ use App\Models\Doubler; use App\Models\Ensemble; use App\Models\Entry; use App\Models\Seat; +use Debugbar; use Illuminate\Http\Request; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Cache; @@ -116,8 +117,44 @@ class SeatAuditionFormController extends Controller $entry->student->full_name().' has declined '.$audition->name); } - public function acceptSeat(Audition $audition, Entry $entry) + public function massDecline(Audition $audition) { + $validData = request()->validate([ + 'decline-below' => ['required', 'integer', 'min:0'], + ]); + $ranker = app(RankAuditionEntries::class); + // Get scored entries in order + $scored_entries = $ranker($audition, 'seating'); + $scored_entries->load(['student.doublers', 'student.school']); + foreach ($scored_entries as $entry) { + Debugbar::info('Starting entry '.$entry->student->full_name()); + if ($entry->hasFlag('declined')) { + Debugbar::info('Skipping '.$entry->student->full_name().' because they have already been declined'); + + continue; + } + if (! $entry->student->isDoublerInEvent($audition->event_id)) { + Debugbar::info('Skipping '.$entry->student->full_name().' because they are not a doubler'); + + continue; + } + if ($entry->student->doublers->where('event_id', $audition->event_id)->first()->accepted_entry) { + Debugbar::info('Skipping '.$entry->student->full_name().' because they have already accepted a seat'); + + continue; + } + $entry->addFlag('declined'); + } + Cache::forget('rank_seating_'.$entry->audition_id); + + return redirect()->route('seating.audition', ['audition' => $audition->id]); + + } + + public function acceptSeat( + Audition $audition, + Entry $entry + ) { $doublerData = Doubler::findDoubler($entry->student_id, $audition->event_id); foreach ($doublerData->entries() as $doublerEntry) { if (! $doublerEntry->totalScore && ! $doublerEntry->hasFlag('declined') && ! $doublerEntry->hasFlag('no_show') && ! $doublerEntry->hasFlag('failed_prelim')) { @@ -136,8 +173,10 @@ class SeatAuditionFormController extends Controller $entry->student->full_name().' has accepted '.$audition->name); } - public function noshow(Audition $audition, Entry $entry) - { + public function noshow( + Audition $audition, + Entry $entry + ) { $recorder = app('App\Actions\Tabulation\EnterNoShow'); try { $msg = $recorder($entry); @@ -148,8 +187,10 @@ class SeatAuditionFormController extends Controller return redirect()->route('seating.audition', [$audition])->with('success', $msg); } - public function draftSeats(Audition $audition, Request $request) - { + public function draftSeats( + Audition $audition, + Request $request + ) { $ranker = app(RankAuditionEntries::class); $validated = $request->validate([ 'ensemble' => ['required', 'array'], @@ -192,15 +233,17 @@ class SeatAuditionFormController extends Controller return redirect()->route('seating.audition', ['audition' => $audition->id]); } - public function clearDraft(Audition $audition) - { + public function clearDraft( + Audition $audition + ) { session()->forget('proposedSeatingArray-'.$audition->id); return redirect()->route('seating.audition', ['audition' => $audition->id]); } - public function publishSeats(Audition $audition) - { + public function publishSeats( + Audition $audition + ) { $publisher = app('App\Actions\Tabulation\PublishSeats'); $seatingProposal = (session('proposedSeatingArray-'.$audition->id)); $proposal = []; @@ -223,8 +266,9 @@ class SeatAuditionFormController extends Controller return redirect()->route('seating.audition', [$audition]); } - public function unpublishSeats(Audition $audition) - { + public function unpublishSeats( + Audition $audition + ) { $unpublisher = app('App\Actions\Tabulation\UnpublishSeats'); $unpublisher($audition); session()->forget('proposedSeatingArray-'.$audition->id); @@ -232,8 +276,10 @@ class SeatAuditionFormController extends Controller return redirect()->route('seating.audition', [$audition]); } - protected function pickRightPanel(Audition $audition, array $seatable) - { + protected function pickRightPanel( + Audition $audition, + array $seatable + ) { if ($audition->hasFlag('seats_published')) { $resultsWindow = new GetAuditionSeats; $rightPanel['view'] = 'tabulation.auditionSeating-show-published-seats'; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 09e5005..744c46e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -99,6 +99,6 @@ class AppServiceProvider extends ServiceProvider SeatingLimit::observe(SeatingLimitObserver::class); EntryFlag::observe(EntryFlagObserver::class); - // Model::preventLazyLoading(! app()->isProduction()); + Model::preventLazyLoading(! app()->isProduction()); } } diff --git a/resources/views/tabulation/auditionSeating.blade.php b/resources/views/tabulation/auditionSeating.blade.php index 6e1f3e8..78771ac 100644 --- a/resources/views/tabulation/auditionSeating.blade.php +++ b/resources/views/tabulation/auditionSeating.blade.php @@ -239,7 +239,6 @@ @endif @else
Cannot seat the audition while there are unresolved doublers.
+