auditionadmin/app/Http/Controllers/Tabulation/SeatAuditionController.php

48 lines
1.6 KiB
PHP

<?php
namespace App\Http\Controllers\Tabulation;
use App\Actions\Tabulation\CalculateEntryScore;
use App\Actions\Tabulation\RankAuditionEntries;
use App\Exceptions\TabulationException;
use App\Http\Controllers\Controller;
use App\Models\Audition;
use App\Models\Entry;
use Illuminate\Http\Request;
class SeatAuditionController extends Controller
{
protected CalculateEntryScore $calc;
protected RankAuditionEntries $ranker;
public function __construct(CalculateEntryScore $calc, RankAuditionEntries $ranker)
{
$this->calc = $calc;
$this->ranker = $ranker;
}
public function __invoke(Request $request, Audition $audition)
{
$entryData = [];
#$entries = Entry::forSeating()->with('student.school')->where('audition_id', $audition->id)->get();
$entries = $this->ranker->rank('seating', $audition);
$entries->load('student.school');
foreach ($entries as $entry) {
$totalScoreColumn = $entry->score_totals[0] >= 0 ?
$entry->score_totals[0] : $entry->score_message;
$entryData[] = [
'rank' => $entry->rank,
'id' => $entry->id,
'studentName' => $entry->student->full_name(),
'schoolName' => $entry->student->school->name,
'drawNumber' => $entry->draw_number,
'totalScore' => $totalScoreColumn,
'fullyScored' => $entry->score_totals[0] >= 0,
];
}
//dd($entryData);
return view('tabulation.auditionSeating', ['entryData' => $entryData, 'audition' => $audition]);
}
}