auditionService = $auditionService; } /** * Handle the incoming request. */ public function __invoke(Request $request) { $publishedAuditions = Audition::seatsPublished() ->with('seats.ensemble') ->with('seats.entry.student') ->with('event.ensembles') ->orderBy('score_order')->get(); $resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) { $seatList = []; // Load the $seatList in the form of $seatlist[audition_id] is an array of seats for that audition // each $seatList[audition_id][] will contain a string with ensemble and seat number and the student object filling it foreach ($publishedAuditions as $audition) { $seats = $audition->seats->groupBy('ensemble_id'); $ensembles = $audition->event->ensembles; foreach ($ensembles as $ensemble) { if (! $seats->has($ensemble->id)) { // If there are no students seated in this ensemble, skip it continue; } foreach ($seats[$ensemble->id] as $seat) { /** @var Seat $seat */ $seatList[$audition->id][] = [ 'seat' => $ensemble->name.' '.$seat->seat, 'student' => $seat->entry->student, ]; } } } return $seatList; }); // $publishedAdvancementAuditions = $this->auditionService->getPublishedAdvancementAuditions(); // $resultsAdvancementList = Cache::rememberForever('resultsAdvancementList', function () use ($publishedAdvancementAuditions) { // $qualifierList = []; // foreach ($publishedAdvancementAuditions as $audition) { // $qualifierList[$audition->id] = Entry::with('flags', 'student.school') // ->where('audition_id', $audition->id) // ->where('for_advancement', true) // ->get()->filter(function (Entry $entry) { // return $entry->hasFlag('will_advance'); // }) // ->sortBy(function (Entry $entry) { // return $entry->student->full_name(true); // }); // } // // return $qualifierList; // }); return view('results.index', compact('publishedAuditions', 'resultsSeatList')); } }