64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\PrelimDefinitionStoreOrUpdateRequest;
|
|
use App\Models\Audition;
|
|
use App\Models\PrelimDefinition;
|
|
use App\Models\Room;
|
|
use App\Models\ScoringGuide;
|
|
|
|
use function view;
|
|
|
|
class PrelimDefinitionController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$prelims = PrelimDefinition::all();
|
|
|
|
return view('admin.prelim_definitions.index', compact('prelims'));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$auditions = Audition::doesntHave('prelimDefinition')->get();
|
|
$rooms = Room::all();
|
|
$guides = ScoringGuide::all();
|
|
$method = 'POST';
|
|
$action = route('admin.prelim_definitions.store');
|
|
$prelim = false;
|
|
|
|
return view('admin.prelim_definitions.createOrUpdate', compact('auditions', 'rooms', 'guides', 'method', 'action', 'prelim'));
|
|
}
|
|
|
|
public function store(PrelimDefinitionStoreOrUpdateRequest $request)
|
|
{
|
|
$validated = $request->validated();
|
|
PrelimDefinition::create($validated);
|
|
|
|
return redirect()->route('admin.prelim_definitions.index')->with('success', 'Prelim definition created');
|
|
}
|
|
|
|
public function edit(PrelimDefinition $prelimDefinition)
|
|
{
|
|
$auditions = Audition::doesntHave('prelimDefinition')->get();
|
|
$rooms = Room::all();
|
|
$guides = ScoringGuide::all();
|
|
$method = 'PATCH';
|
|
$action = route('admin.prelim_definitions.update', $prelimDefinition);
|
|
$prelim = $prelimDefinition;
|
|
|
|
return view('admin.prelim_definitions.createOrUpdate', compact('auditions', 'rooms', 'guides', 'method', 'action', 'prelim'));
|
|
|
|
}
|
|
|
|
public function update(PrelimDefinition $prelimDefinition, PrelimDefinitionStoreOrUpdateRequest $request)
|
|
{
|
|
$validated = $request->validated();
|
|
$prelimDefinition->update($validated);
|
|
|
|
return redirect()->route('admin.prelim_definitions.index')->with('success', 'Prelim definition updated');
|
|
}
|
|
}
|