getAuditions method of AuditionCacheService will filter for seating or advancement
This commit is contained in:
parent
9e89fdf751
commit
607dd2460c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -16,8 +16,12 @@
|
|||
<x-layout.app>
|
||||
<x-slot:page_title>Test Page</x-slot:page_title>
|
||||
@php
|
||||
dump(auditionSetting('auditionName'));
|
||||
dump($auditionService->getAuditions());
|
||||
@endphp
|
||||
|
||||
@foreach($auditionService->getAuditions() as $a)
|
||||
{{ $a->name }} <br>
|
||||
@endforeach
|
||||
|
||||
|
||||
</x-layout.app>
|
||||
|
|
|
|||
Loading…
Reference in New Issue