cacheKey, 3600, function () { if (App::environment('local')) { Session::flash('success', 'Audition Cache Updated'); } return Audition::with(['scoringGuide.subscores', 'judges']) ->withCount('judges') ->withCount('entries') ->orderBy('score_order') ->get() ->keyBy('id'); }); } public function getAudition($id): Audition { return $this->getAuditions()->firstWhere('id', $id); } public function refreshCache() { Cache::forget($this->cacheKey); $this->getAuditions(); } public function clearCache() { if (App::environment('local')) { Session::flash('success', 'Audition Cache Cleared'); } Cache::forget($this->cacheKey); } public function getPublishedAuditions() { $cacheKey = 'publishedAuditions'; return Cache::remember( $cacheKey, now()->addHour(), function () { return Audition::orderBy('score_order')->get()->filter(fn ($audition) => $audition->hasFlag('seats_published')); }); } }