diff --git a/app/Http/Controllers/Tabulation/SeatAuditionFormController.php b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php index 6893a20..a01e3ed 100644 --- a/app/Http/Controllers/Tabulation/SeatAuditionFormController.php +++ b/app/Http/Controllers/Tabulation/SeatAuditionFormController.php @@ -6,6 +6,7 @@ use App\Actions\Tabulation\GetAuditionSeats; use App\Actions\Tabulation\RankAuditionEntries; use App\Http\Controllers\Controller; use App\Models\Audition; +use App\Models\Doubler; use Illuminate\Http\Request; class SeatAuditionFormController extends Controller @@ -15,7 +16,7 @@ class SeatAuditionFormController extends Controller $ranker = app(RankAuditionEntries::class); // Get scored entries in order $scored_entries = $ranker($audition, 'seating'); - + $scored_entries->load(['student.doublers', 'student.school']); // Get unscored entries sorted by draw number $unscored_entries = $audition->entries() ->whereDoesntHave('totalScore') @@ -49,29 +50,11 @@ class SeatAuditionFormController extends Controller ->orderBy('draw_number', 'asc') ->get(); - // Get Doubler Data - $doubler_data = []; - foreach ($scored_entries as $e) { - if ($e->student->isDoublerInEvent($audition->event_id)) { - // get the other entries for this student - $doubler_data[$e->id]['entries'] = $e->student->entriesForEvent($e->audition->event_id); - - // How many of this student's entries have been declined - $declined_count = $doubler_data[$e->id]['entries']->filter(function ($entry) { - return $entry->hasFlag('declined'); - })->count(); - - // set status - // declined status is easy - if ($e->hasFlag('declined')) { - $doubler_data[$e->id]['status'] = 'declined'; - } elseif ($doubler_data[$e->id]['entries']->count() - $declined_count == 1) { - $doubler_data[$e->id]['status'] = 'accepted'; - } else { - $doubler_data[$e->id]['status'] = 'undecided'; - } - } - } + // Get Doublers + $doublerData = Doubler::where('event_id', $audition->event_id) + ->whereIn('student_id', $scored_entries->pluck('student_id')) + ->get() + ->keyBy('student_id'); return view('tabulation.auditionSeating', compact('audition', @@ -79,7 +62,7 @@ class SeatAuditionFormController extends Controller 'unscored_entries', 'noshow_entries', 'failed_prelim_entries', - 'doubler_data', ) + 'doublerData') ); } diff --git a/app/Models/Doubler.php b/app/Models/Doubler.php index 3c8e370..ad7c4f9 100644 --- a/app/Models/Doubler.php +++ b/app/Models/Doubler.php @@ -4,7 +4,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Support\Collection; class Doubler extends Model { @@ -29,7 +28,7 @@ class Doubler extends Model return $this->belongsTo(Event::class); } - public function entries(): Collection + public function entries() { return Entry::whereIn('id', $this->entries)->get(); } diff --git a/app/Models/Student.php b/app/Models/Student.php index 6b3c943..f68c4b4 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -95,6 +95,11 @@ class Student extends Model return $this->hasMany(DoublerRequest::class); } + public function doublers(): HasMany + { + return $this->hasMany(Doubler::class); + } + public function isDoublerInEvent(Event|int $event): bool { $eventId = $event instanceof Event ? $event->id : $event; diff --git a/app/Observers/EntryFlagObserver.php b/app/Observers/EntryFlagObserver.php new file mode 100644 index 0000000..e66d8cc --- /dev/null +++ b/app/Observers/EntryFlagObserver.php @@ -0,0 +1,49 @@ +isProduction()); + // Model::preventLazyLoading(! app()->isProduction()); } } diff --git a/resources/views/tabulation/auditionSeating-doubler-block-OLD.blade.php b/resources/views/tabulation/auditionSeating-doubler-block-OLD.blade.php new file mode 100644 index 0000000..9f7635d --- /dev/null +++ b/resources/views/tabulation/auditionSeating-doubler-block-OLD.blade.php @@ -0,0 +1,55 @@ +@php($doublerButtonClasses = 'hidden rounded-md bg-white px-2.5 py-1.5 text-xs text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:block') +
+ + {{ $double['auditionName'] }} - {{ $double['status'] }} + +
+Ranked {{ $double['rank'] }}
+{{ $double['unscored_entries'] }} Unscored
+Complete
--}} + +{{--In Progres Badge--}} +{{--In Progress
--}} diff --git a/resources/views/tabulation/auditionSeating-doubler-block.blade.php b/resources/views/tabulation/auditionSeating-doubler-block.blade.php index 9f7635d..133b19a 100644 --- a/resources/views/tabulation/auditionSeating-doubler-block.blade.php +++ b/resources/views/tabulation/auditionSeating-doubler-block.blade.php @@ -1,55 +1,35 @@ -@php($doublerButtonClasses = 'hidden rounded-md bg-white px-2.5 py-1.5 text-xs text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:block') -- - {{ $double['auditionName'] }} - {{ $double['status'] }} - -
-Ranked {{ $double['rank'] }}
-{{ $double['unscored_entries'] }} Unscored
-Complete
--}} - -{{--In Progres Badge--}} -{{--In Progress
--}} +Request: {{$entry['doublerRequest']}}
@endif - @include('tabulation.auditionSeating-doubler-block') + @include('tabulation.auditionSeating-doubler-block-OLD') {{-- DOUBLER