User side entries can set seating and advancement options
This commit is contained in:
parent
97c15c4fef
commit
0e8710a771
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\AuditionChange;
|
||||
use App\Models\Audition;
|
||||
use App\Models\Entry;
|
||||
use App\Models\School;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use function abort;
|
||||
|
||||
class EntryController extends Controller
|
||||
|
|
@ -16,34 +15,45 @@ class EntryController extends Controller
|
|||
public function index()
|
||||
{
|
||||
|
||||
$entries = Auth::user()->entries()->with(['student','audition'])->get();
|
||||
$entries = Auth::user()->entries()->with(['student', 'audition'])->get();
|
||||
$auditions = Audition::deadlineNotPast();
|
||||
$students = Auth::user()->students;
|
||||
|
||||
return view('entries.index',['entries' => $entries, 'students' => $students, 'auditions' => $auditions]);
|
||||
return view('entries.index', ['entries' => $entries, 'students' => $students, 'auditions' => $auditions]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
if ($request->user()->cannot('create', Entry::class)) abort(403);
|
||||
if ($request->user()->cannot('create', Entry::class)) {
|
||||
abort(403);
|
||||
}
|
||||
// TODO write custom rule to verify the combination of student and audition is unique
|
||||
$request->validate([
|
||||
$validData = $request->validate([
|
||||
'student_id' => ['required', 'exists:students,id'],
|
||||
'audition_id' => ['required', 'exists:auditions,id']
|
||||
'audition_id' => ['required', 'exists:auditions,id'],
|
||||
]);
|
||||
|
||||
$validData['for_seating'] = $request->get('for_seating') ? 1 : 0;
|
||||
$validData['for_advancement'] = $request->get('for_advancement') ? 1 : 0;
|
||||
|
||||
$entry = Entry::create([
|
||||
'student_id' => request('student_id'),
|
||||
'audition_id' => request('audition_id')
|
||||
'student_id' => $validData['student_id'],
|
||||
'audition_id' => $validData['audition_id'],
|
||||
'for_seating' => $validData['for_seating'],
|
||||
'for_advancement' => $validData['for_advancement'],
|
||||
]);
|
||||
|
||||
return redirect('/entries');
|
||||
}
|
||||
|
||||
public function destroy(Request $request, Entry $entry)
|
||||
{
|
||||
if ($request->user()->cannot('delete', $entry)) abort(403);
|
||||
if ($request->user()->cannot('delete', $entry)) {
|
||||
abort(403);
|
||||
}
|
||||
$entry->delete();
|
||||
return redirect('/entries')->with('success','The ' . $entry->audition->name . 'entry for ' . $entry->student->full_name(). 'has been deleted.');
|
||||
|
||||
return redirect('/entries')->with('success', 'The '.$entry->audition->name.'entry for '.$entry->student->full_name().'has been deleted.');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<x-slot:section_name>Add Entry</x-slot:section_name>
|
||||
<x-form.form method="POST" action="/entries" class="pt-6 pb-8">
|
||||
|
||||
<x-form.body-grid columns="7" class="max-w-full" x-data="studentAuditionFilter()">
|
||||
<x-form.body-grid columns="6" class="max-w-full" x-data="studentAuditionFilter()">
|
||||
|
||||
<x-form.select name="student_id" colspan="3" x-model="selectedStudentId" @change="filterAuditions">
|
||||
<x-slot:label>Student</x-slot:label>
|
||||
|
|
@ -29,6 +29,23 @@
|
|||
</template>
|
||||
</x-form.select>
|
||||
|
||||
@if(auditionSetting('advanceTo'))
|
||||
<div class="col-span-6 align-top">
|
||||
<x-form.checkbox name="for_seating"
|
||||
label="Enter for {{ auditionSetting('auditionAbbreviation') }}"
|
||||
checked />
|
||||
</div>
|
||||
<div class="col-span-5 align-top">
|
||||
<x-form.checkbox name="for_advancement"
|
||||
label="Enter for {{ auditionSetting('advanceTo') }}"
|
||||
checked />
|
||||
</div>
|
||||
@else
|
||||
<input type="hidden" name="for_seating" value="on">
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
<x-form.button class="mt-6">Save</x-form.button>
|
||||
</x-form.body-grid>
|
||||
</x-form.form>
|
||||
|
|
@ -45,6 +62,10 @@
|
|||
<x-table.th first>Name</x-table.th>
|
||||
<x-table.th>Grade</x-table.th>
|
||||
<x-table.th>Audition</x-table.th>
|
||||
@if(auditionSetting('advanceTo'))
|
||||
<x-table.th>{{ auditionSetting('auditionAbbreviation') }}</x-table.th>
|
||||
<x-table.th>{{ auditionSetting('advanceTo') }}</x-table.th>
|
||||
@endif
|
||||
<x-table.th spacer_only>
|
||||
<span class="sr-only">Edit</span>
|
||||
</x-table.th>
|
||||
|
|
@ -56,6 +77,24 @@
|
|||
<x-table.td first>{{ $entry->student->full_name(true) }}</x-table.td>
|
||||
<x-table.td>{{ $entry->student->grade }}</x-table.td>
|
||||
<x-table.td>{{ $entry->audition->name }}</x-table.td>
|
||||
|
||||
@if(auditionSetting('advanceTo'))
|
||||
<x-table.td>
|
||||
@if($entry->for_seating)
|
||||
<x-icons.checkmark color="green" />
|
||||
@else
|
||||
<x-icons.circle-slash-no color="red" />
|
||||
@endif
|
||||
</x-table.td>
|
||||
<x-table.td>
|
||||
@if($entry->for_advancement)
|
||||
<x-icons.checkmark color="green" />
|
||||
@else
|
||||
<x-icons.circle-slash-no color="red" />
|
||||
@endif
|
||||
</x-table.td>
|
||||
@endif
|
||||
|
||||
<x-table.td for_button>
|
||||
@if( $entry->audition->entry_deadline >= now())
|
||||
<form method="POST" action="/entries/{{ $entry->id }}" class="inline">
|
||||
|
|
|
|||
Loading…
Reference in New Issue