92 lines
3.1 KiB
PHP
92 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Tabulation;
|
|
|
|
use App\Actions\Tabulation\GetAuditionSeats;
|
|
use App\Actions\Tabulation\RankAuditionEntries;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Audition;
|
|
use Illuminate\Http\Request;
|
|
|
|
class SeatAuditionFormController extends Controller
|
|
{
|
|
public function showForm(Request $request, Audition $audition)
|
|
{
|
|
$ranker = app(RankAuditionEntries::class);
|
|
// Get scored entries in order
|
|
$scored_entries = $ranker($audition, 'seating');
|
|
|
|
// Get unscored entries sorted by draw number
|
|
$unscored_entries = $audition->entries()
|
|
->whereDoesntHave('totalScore')
|
|
->whereDoesntHave('flags', function ($query) {
|
|
$query->where('flag_name', 'no_show');
|
|
})
|
|
->whereDoesntHave('flags', function ($query) {
|
|
$query->where('flag_name', 'failed_prelim');
|
|
})
|
|
->with('student.school')
|
|
->orderBy('draw_number', 'asc')
|
|
->get();
|
|
|
|
// Get no show entries sorted by draw number
|
|
$noshow_entries = $audition->entries()
|
|
->whereDoesntHave('totalScore')
|
|
->whereHas('flags', function ($query) {
|
|
$query->where('flag_name', 'no_show');
|
|
})
|
|
->with('student.school')
|
|
->orderBy('draw_number', 'asc')
|
|
->get();
|
|
|
|
// Get failed prelim entries sorted by draw number
|
|
$failed_prelim_entries = $audition->entries()
|
|
->whereDoesntHave('totalScore')
|
|
->whereHas('flags', function ($query) {
|
|
$query->where('flag_name', 'failed_prelim');
|
|
})
|
|
->with('student.school')
|
|
->orderBy('draw_number', 'asc')
|
|
->get();
|
|
|
|
// Get Doubler Data
|
|
$doubler_data = [];
|
|
foreach ($scored_entries as $e) {
|
|
if ($e->student->isDoublerInEvent($audition->event_id)) {
|
|
$doubler_data[$e->id] = $e->student->entriesForEvent($e->audition->event_id);
|
|
}
|
|
}
|
|
|
|
return view('tabulation.auditionSeating',
|
|
compact('audition',
|
|
'scored_entries',
|
|
'unscored_entries',
|
|
'noshow_entries',
|
|
'failed_prelim_entries',
|
|
'doubler_data', )
|
|
);
|
|
}
|
|
|
|
protected function pickRightPanel(Audition $audition, array $seatable)
|
|
{
|
|
if ($audition->hasFlag('seats_published')) {
|
|
$resultsWindow = new GetAuditionSeats;
|
|
$rightPanel['view'] = 'tabulation.auditionSeating-show-published-seats';
|
|
$rightPanel['data'] = $resultsWindow($audition);
|
|
|
|
return $rightPanel;
|
|
}
|
|
if ($seatable['allScored'] == false || $seatable['doublersResolved'] == false) {
|
|
$rightPanel['view'] = 'tabulation.auditionSeating-unable-to-seat-card';
|
|
$rightPanel['data'] = $seatable;
|
|
|
|
return $rightPanel;
|
|
}
|
|
|
|
$rightPanel['view'] = 'tabulation.auditionSeating-right-complete-not-published';
|
|
$rightPanel['data'] = $this->auditionService->getSeatingLimits($audition);
|
|
|
|
return $rightPanel;
|
|
}
|
|
}
|