From 0c6c098edf63dd269b59107c5ba2ef5e477eb06a Mon Sep 17 00:00:00 2001 From: Matt Young Date: Sun, 30 Jun 2024 21:45:49 -0500 Subject: [PATCH] Last touches on Audition model --- app/Http/Controllers/EntryController.php | 2 +- app/Models/Audition.php | 24 +++++-- database/factories/EventFactory.php | 4 +- .../views/admin/auditions/index.blade.php | 64 +++++++++---------- tests/Feature/Models/AuditionTest.php | 28 +++++++- 5 files changed, 79 insertions(+), 43 deletions(-) diff --git a/app/Http/Controllers/EntryController.php b/app/Http/Controllers/EntryController.php index 9243145..6c16d8f 100644 --- a/app/Http/Controllers/EntryController.php +++ b/app/Http/Controllers/EntryController.php @@ -19,7 +19,7 @@ class EntryController extends Controller $entries = $entries->sortBy(function ($entry) { return $entry->student->last_name.$entry->student->first_name.$entry->audition->score_order; }); - $auditions = Audition::deadlineNotPast(); + $auditions = Audition::open()->get(); $students = Auth::user()->students; return view('entries.index', ['entries' => $entries, 'students' => $students, 'auditions' => $auditions]); diff --git a/app/Models/Audition.php b/app/Models/Audition.php index 836109a..66be60c 100644 --- a/app/Models/Audition.php +++ b/app/Models/Audition.php @@ -26,10 +26,6 @@ class Audition extends Model protected $scored_entries_count; //Set by TabulationService - public static function deadlineNotPast() - { - return Audition::where('entry_deadline', '>=', now())->get(); - } public function event(): BelongsTo { @@ -51,7 +47,7 @@ class Audition extends Model return $this->belongsTo(ScoringGuide::class); } - public function dislpay_fee(): string + public function display_fee(): string { return '$'.number_format($this->entry_fee / 100, 2); } @@ -135,7 +131,7 @@ class Audition extends Model } /** - * @return BelongsToMany|\App\Models\User[] + * @return BelongsToMany|User[] */ public function judges(): array|BelongsToMany { @@ -201,4 +197,20 @@ class Audition extends Model { $query->where('for_advancement', 1); } + + public function scopeSeatsPublished(Builder $query): Builder + { + return $query->whereHas('flags', function (Builder $query) { + $query->where('flag_name', 'seats_published'); + }); + + } + + public function scopeAdvancementPublished(Builder $query): Builder + { + return $query->whereHas('flags', function (Builder $query) { + $query->where('flag_name', 'advancement_published'); + }); + + } } diff --git a/database/factories/EventFactory.php b/database/factories/EventFactory.php index 006a07b..ae4a7c9 100644 --- a/database/factories/EventFactory.php +++ b/database/factories/EventFactory.php @@ -17,9 +17,7 @@ class EventFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->randomElement([ - 'Concert Auditions', 'Jazz Auditions ', - ]).$this->faker->randomNumber(1), + 'name' => $this->faker->name(), ]; } } diff --git a/resources/views/admin/auditions/index.blade.php b/resources/views/admin/auditions/index.blade.php index 4f84350..527d197 100644 --- a/resources/views/admin/auditions/index.blade.php +++ b/resources/views/admin/auditions/index.blade.php @@ -25,40 +25,41 @@
- - @foreach($auditions as $audition) - - {{ $audition->event->name }} - {{ $audition->name }} - {{ $audition->entry_deadline }} - {{ $audition->dislpay_fee() }} - {{ $audition->minimum_grade }} - {{ $audition->maximum_grade }} - @if(auditionSetting('advanceTo')) - - @if($audition->for_seating) - - @else - - @endif - - - @if($audition->for_advancement) - - @else - - @endif - - @endif - {{ $audition->entries->count() }} - - @endforeach - + + @foreach($auditions as $audition) + + {{ $audition->event->name }} + {{ $audition->name }} + {{ $audition->entry_deadline }} + {{ $audition->display_fee() }} + {{ $audition->minimum_grade }} - {{ $audition->maximum_grade }} + @if(auditionSetting('advanceTo')) + + @if($audition->for_seating) + + @else + + @endif + + + @if($audition->for_advancement) + + @else + + @endif + + @endif + {{ $audition->entries->count() }} + + @endforeach +
-{{-- {{ $auditions->links('vendor.pagination.simple-audition') }}--}} + {{-- {{ $auditions->links('vendor.pagination.simple-audition') }}--}}