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

45 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Tabulation;
use App\Actions\Tabulation\CalculateEntryScore;
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;
public function __construct(CalculateEntryScore $calc)
{
$this->calc = $calc;
}
public function __invoke(Request $request, Audition $audition)
{
$entryData = [];
$entries = Entry::forSeating()->with('student.school')->where('audition_id', $audition->id)->get();
foreach ($entries as $entry) {
try {
$totalScore = $this->calc->calculate('seating', $entry);
} catch (TabulationException $ex) {
$totalScore[0] = $ex->getMessage();
}
$entryData[] = [
'rank' => 'not implemented',
'id' => $entry->id,
'studentName' => $entry->student->full_name(),
'schoolName' => $entry->student->school->name,
'drawNumber' => $entry->draw_number,
'totalScore' => $totalScore[0],
];
}
//dd($entryData);
return view('tabulation.auditionSeating', ['entryData' => $entryData, 'audition' => $audition]);
}
}