From 607dd2460c477cb173ff602a62582ca8451ac80d Mon Sep 17 00:00:00 2001 From: Matt Young Date: Tue, 25 Jun 2024 23:48:01 -0500 Subject: [PATCH] getAuditions method of AuditionCacheService will filter for seating or advancement --- app/Services/AuditionCacheService.php | 13 +++++++++++-- resources/views/test.blade.php | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Services/AuditionCacheService.php b/app/Services/AuditionCacheService.php index bbe22c9..e1a1300 100644 --- a/app/Services/AuditionCacheService.php +++ b/app/Services/AuditionCacheService.php @@ -24,9 +24,9 @@ class AuditionCacheService * Return or fill cache of auditions including the audition, * scoringGuide.subscores, judges, judges_count, and entries_count */ - public function getAuditions(): \Illuminate\Database\Eloquent\Collection + public function getAuditions($mode = 'seating'): \Illuminate\Database\Eloquent\Collection { - return Cache::remember($this->cacheKey, 3600, function () { + $auditions = Cache::remember($this->cacheKey, 3600, function () { if (App::environment('local')) { Session::flash('success', 'Audition Cache Updated'); } @@ -38,6 +38,15 @@ class AuditionCacheService ->get() ->keyBy('id'); }); + + switch ($mode) { + case 'seating': + return $auditions->filter(fn ($audition) => $audition->for_seating); + case 'advancement': + return $auditions->filter(fn ($audition) => $audition->for_advancement); + default: + return $auditions; + } } public function getAudition($id): Audition diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php index cf848a5..44d7e44 100644 --- a/resources/views/test.blade.php +++ b/resources/views/test.blade.php @@ -16,8 +16,12 @@ Test Page @php - dump(auditionSetting('auditionName')); + dump($auditionService->getAuditions()); @endphp + @foreach($auditionService->getAuditions() as $a) + {{ $a->name }}
+ @endforeach +