MEOBDA rules - display form to add a nomination
This commit is contained in:
parent
80e66aa49a
commit
f57fa84247
|
|
@ -92,7 +92,40 @@ class MeobdaNominationAdminController extends Controller implements NominationAd
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
// TODO: Implement create() method.
|
$target_ensemble = null;
|
||||||
|
$instrumentation = null;
|
||||||
|
$students = null;
|
||||||
|
if (request()->get('ensemble')) {
|
||||||
|
$validData = request()->validate([
|
||||||
|
'ensemble' => 'nullable|exists:nomination_ensembles,id',
|
||||||
|
]);
|
||||||
|
$target_ensemble = NominationEnsemble::find($validData['ensemble']);
|
||||||
|
|
||||||
|
// Get viable students for entering
|
||||||
|
$students = Student::where('grade', '<=', $target_ensemble->maximum_grade)
|
||||||
|
->where('grade', '>=', $target_ensemble->minimum_grade)
|
||||||
|
->with('school')
|
||||||
|
->join('schools', 'schools.id', '=', 'students.school_id')
|
||||||
|
->orderBy('schools.name', 'asc')
|
||||||
|
->orderBy('students.last_name', 'asc')
|
||||||
|
->orderBy('students.first_name', 'asc')
|
||||||
|
->get(['students.*']);
|
||||||
|
|
||||||
|
// Remove students already nominated
|
||||||
|
$nominated_student_ids = NominationEnsembleEntry::where('nomination_ensemble_id',
|
||||||
|
$target_ensemble->id)->pluck('student_id')->all();
|
||||||
|
|
||||||
|
$students = $students->reject(function ($student) use ($nominated_student_ids) {
|
||||||
|
return in_array($student->id, $nominated_student_ids);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get current instrumentation of target ensemble
|
||||||
|
$instrumentation = $this->get_ensemble_instrumentation($target_ensemble);
|
||||||
|
}
|
||||||
|
$ensembles = NominationEnsemble::all();
|
||||||
|
|
||||||
|
return view('nomination_ensembles.meobda.admin.nomination-create',
|
||||||
|
compact('ensembles', 'target_ensemble', 'students', 'instrumentation'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store()
|
public function store()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<x-card.card class="mx-auto max-w-lg">
|
||||||
|
<x-card.heading>Choose Ensemble</x-card.heading>
|
||||||
|
<div class="px-3">
|
||||||
|
@foreach($ensembles as $ensemble)
|
||||||
|
<x-form.button class="my-3"
|
||||||
|
href="{{ route('nomination.admin.create',['ensemble' => $ensemble->id]) }}">{{ $ensemble->name }}</x-form.button>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</x-card.card>
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
<x-layout.app>
|
||||||
|
@if(!$target_ensemble)
|
||||||
|
@include('nomination_ensembles.meobda.admin.nomination-create-choose_ensemble')
|
||||||
|
@else
|
||||||
|
<x-card.card class="mx-auto max-w-lg">
|
||||||
|
<x-card.heading>New Nomination - {{ $target_ensemble->name }}</x-card.heading>
|
||||||
|
<x-form.form class="mb-3">
|
||||||
|
<x-form.select name="student">
|
||||||
|
<x-slot:label>Student</x-slot:label>
|
||||||
|
@foreach($students as $student)
|
||||||
|
<option value="{{$student->id}}">{{ $student->school->name }} - {{ $student->full_name() }} - Grade: {{ $student->grade }}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-form.select>
|
||||||
|
<x-form.select name="instrument">
|
||||||
|
<x-slot:label>Instrument</x-slot:label>
|
||||||
|
@foreach($target_ensemble->data['instruments'] as $instrument)
|
||||||
|
<option value="{{$instrument['name']}}">{{$instrument['name']}}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-form.select>
|
||||||
|
<x-form.select name="split">
|
||||||
|
<x-slot:label>Split</x-slot:label>
|
||||||
|
<option value="---">None Assigned</option>
|
||||||
|
@foreach($target_ensemble->data['split_names'] as $split)
|
||||||
|
<option value="{{$split}}")>{{$split}}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-form.select>
|
||||||
|
<x-form.field name="seat" value="0" label_text="Seat (0 to leave unassigned)" type="number"/>
|
||||||
|
<x-form.footer submit-button-text="Create Nomination"></x-form.footer>
|
||||||
|
</x-form.form>
|
||||||
|
</x-card.card>
|
||||||
|
|
||||||
|
{{-- Display current instrumentation--}}
|
||||||
|
<x-card.card class="mt-3">
|
||||||
|
<x-card.heading>Current Instrumentation (before any changes)</x-card.heading>
|
||||||
|
<x-table.table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<x-table.th> </x-table.th>
|
||||||
|
@foreach($target_ensemble->data['split_names'] as $split)
|
||||||
|
<x-table.th>{{$split}}</x-table.th>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<x-table.body>
|
||||||
|
@foreach($target_ensemble->data['instruments'] as $instrument)
|
||||||
|
<tr>
|
||||||
|
<x-table.td>{{$instrument['name']}}</x-table.td>
|
||||||
|
@foreach($target_ensemble->data['split_names'] as $split)
|
||||||
|
<x-table.td>{{ $instrumentation[$split][$instrument['name']] }}</x-table.td>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</x-table.body>
|
||||||
|
</x-table.table>
|
||||||
|
</x-card.card>
|
||||||
|
@endif
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -48,6 +48,8 @@
|
||||||
</x-form.form>
|
</x-form.form>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
|
|
||||||
|
<x-form.button class="mb-3" href="{{ route('nomination.admin.create') }}">Add Nomination</x-form.button>
|
||||||
|
|
||||||
|
|
||||||
<div class="px-3">
|
<div class="px-3">
|
||||||
{{ $nominations->onEachSide(3)->links() }}
|
{{ $nominations->onEachSide(3)->links() }}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('nomination
|
||||||
Route::get('/', 'index')->name('nomination.admin.index');
|
Route::get('/', 'index')->name('nomination.admin.index');
|
||||||
Route::get('/{nominationEnsembleEntry}/edit', 'edit')->name('nomination.admin.edit');
|
Route::get('/{nominationEnsembleEntry}/edit', 'edit')->name('nomination.admin.edit');
|
||||||
Route::patch('/{nominationEnsembleEntry}', 'update')->name('nomination.admin.update');
|
Route::patch('/{nominationEnsembleEntry}', 'update')->name('nomination.admin.update');
|
||||||
|
Route::get('/create', 'create')->name('nomination.admin.create');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('seating/')->controller(NominationSeatingController::class)->group(function () {
|
Route::prefix('seating/')->controller(NominationSeatingController::class)->group(function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue