getAuditions method of AuditionCacheService will filter for seating or advancement

This commit is contained in:
Matt Young 2024-06-25 23:48:01 -05:00
parent 9e89fdf751
commit 607dd2460c
2 changed files with 16 additions and 3 deletions

View File

@ -24,9 +24,9 @@ class AuditionCacheService
* Return or fill cache of auditions including the audition, * Return or fill cache of auditions including the audition,
* scoringGuide.subscores, judges, judges_count, and entries_count * 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')) { if (App::environment('local')) {
Session::flash('success', 'Audition Cache Updated'); Session::flash('success', 'Audition Cache Updated');
} }
@ -38,6 +38,15 @@ class AuditionCacheService
->get() ->get()
->keyBy('id'); ->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 public function getAudition($id): Audition

View File

@ -16,8 +16,12 @@
<x-layout.app> <x-layout.app>
<x-slot:page_title>Test Page</x-slot:page_title> <x-slot:page_title>Test Page</x-slot:page_title>
@php @php
dump(auditionSetting('auditionName')); dump($auditionService->getAuditions());
@endphp @endphp
@foreach($auditionService->getAuditions() as $a)
{{ $a->name }} <br>
@endforeach
</x-layout.app> </x-layout.app>