58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Audition;
|
|
use App\Models\Entry;
|
|
|
|
use function compact;
|
|
|
|
class MonitorController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
if (! auth()->user()->hasFlag('monitor')) {
|
|
abort(403);
|
|
}
|
|
|
|
$auditions = Audition::orderBy('score_order')->with('flags')->get();
|
|
$audition = null;
|
|
|
|
return view('monitor.index', compact('audition', 'auditions'));
|
|
}
|
|
|
|
public function auditionStatus(Audition $audition)
|
|
{
|
|
if (! auth()->user()->hasFlag('monitor')) {
|
|
abort(403);
|
|
}
|
|
|
|
if ($audition->hasFlag('seats_published') || $audition->hasFlag('advancement_published')) {
|
|
return redirect()->route('monitor.index')->with('error', 'Results for that audition are published');
|
|
}
|
|
|
|
$auditions = Audition::orderBy('score_order')->with('flags')->get();
|
|
$entries = $audition->entries()->with('flags')->with('student.school')->withCount([
|
|
'prelimScoreSheets', 'scoreSheets',
|
|
])->orderBy('draw_number')->get();
|
|
|
|
return view('monitor.index', compact('audition', 'auditions', 'entries'));
|
|
}
|
|
|
|
public function toggleNoShow(Entry $entry)
|
|
{
|
|
if ($entry->audition->hasFlag('seats_published') || $entry->audition->hasFlag('advancement_published')) {
|
|
return redirect()->route('monitor.index')->with('error', 'Results for that audition are published');
|
|
}
|
|
|
|
if ($entry->hasFlag('no_show')) {
|
|
$entry->removeFlag('no_show');
|
|
|
|
return redirect()->back()->with('success', 'No Show Flag Cleared');
|
|
}
|
|
$entry->addFlag('no_show');
|
|
|
|
return redirect()->back()->with('success', 'No Show Entered');
|
|
}
|
|
}
|