calc = $calc; $this->ranker = $ranker; $this->doublerService = $doublerService; $this->entryService = $entryService; $this->auditionService = $auditionService; } public function __invoke(Request $request, Audition $audition) { // If a seating proposal was posted, deal wth it if ($request->method() == 'POST') { $requestedEnsembleAccepts = $request->input('ensembleAccept'); } else { $requestedEnsembleAccepts = false; } $entryData = []; $entries = $this->ranker->rank('seating', $audition); $entries->load('student.school'); $seatable = [ 'allScored' => true, 'doublersResolved' => true, ]; foreach ($entries as $entry) { $totalScoreColumn = 'No Score'; $fullyScored = false; if ($entry->score_totals) { $totalScoreColumn = $entry->score_totals[0] >= 0 ? $entry->score_totals[0] : $entry->score_message; $fullyScored = $entry->score_totals[0] >= 0; } $doublerData = $this->doublerService->entryDoublerData($entry); $entryData[] = [ 'rank' => $entry->rank, 'id' => $entry->id, 'studentName' => $entry->student->full_name(), 'schoolName' => $entry->student->school->name, 'drawNumber' => $entry->draw_number, 'totalScore' => $totalScoreColumn, 'fullyScored' => $fullyScored, 'doubleData' => $doublerData, ]; // If this entries double decision isn't made, block seating if ($doublerData && $doublerData[$entry->id]['status'] == 'undecided') { $seatable['doublersResolved'] = false; } // If entry is unscored, block seating if (! $fullyScored) { $seatable['allScored'] = false; } } $rightPanel = $this->pickRightPanel($audition, $seatable); $seatableEntries = []; if ($seatable['doublersResolved'] && $seatable['allScored']) { $seatableEntries = $entries->reject(function ($entry) { if ($entry->hasFlag('declined')) { return true; } if ($entry->hasFlag('no_show')) { return true; } return false; }); } return view('tabulation.auditionSeating', compact('entryData', 'audition', 'rightPanel', 'seatableEntries', 'requestedEnsembleAccepts')); } protected function pickRightPanel(Audition $audition, array $seatable) { if ($audition->hasFlag('seats_published')) { $resultsWindow = new GetAuditionSeats; $rightPanel['view'] = 'tabulation.auditionSeating-show-published-seats'; $rightPanel['data'] = $resultsWindow($audition); return $rightPanel; } if ($seatable['allScored'] == false || $seatable['doublersResolved'] == false) { $rightPanel['view'] = 'tabulation.auditionSeating-unable-to-seat-card'; $rightPanel['data'] = $seatable; return $rightPanel; } $rightPanel['view'] = 'tabulation.auditionSeating-right-complete-not-published'; $rightPanel['data'] = $this->auditionService->getSeatingLimits($audition); return $rightPanel; } }