auditionCacheService = $auditionCacheService; $this->seatingService = $seatingService; } /** * Handle the incoming request. */ public function __invoke(Request $request) { $publishedAuditions = $this->auditionCacheService->getPublishedAuditions(); $resultsSeatList = Cache::rememberForever('resultsSeatList', function () use ($publishedAuditions) { $seatList = []; foreach ($publishedAuditions as $audition) { $seats = $this->seatingService->getSeatsForAudition($audition->id); $ensembles = $this->seatingService->getEnsemblesForEvent($audition->event_id); 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; }); return view('results.index', compact('publishedAuditions', 'resultsSeatList')); } }