Scobda nomination ensembles #106
|
|
@ -8,15 +8,15 @@ interface NominationEnsembleEntryController
|
||||||
{
|
{
|
||||||
public function index();
|
public function index();
|
||||||
|
|
||||||
public function show(NominationEnsembleEntry $ensemble);
|
public function show(NominationEnsembleEntry $entry);
|
||||||
|
|
||||||
public function create();
|
public function create();
|
||||||
|
|
||||||
public function store();
|
public function store();
|
||||||
|
|
||||||
public function edit(NominationEnsembleEntry $ensemble);
|
public function edit(NominationEnsembleEntry $entry);
|
||||||
|
|
||||||
public function update(NominationEnsembleEntry $ensemble);
|
public function update(NominationEnsembleEntry $entry);
|
||||||
|
|
||||||
public function destroy(NominationEnsembleEntry $ensemble);
|
public function destroy(NominationEnsembleEntry $entry);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,11 @@ class ScobdaNominationEnsembleEntryController extends Controller implements Nomi
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('nomination_ensembles.scobda.entries.index',
|
return view('nomination_ensembles.scobda.entries.index',
|
||||||
compact('ensembles', 'availableStudents', 'availableInstruments', 'nominatedStudents', 'nominationsAvailable'));
|
compact('ensembles', 'availableStudents', 'availableInstruments', 'nominatedStudents',
|
||||||
|
'nominationsAvailable'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(NominationEnsembleEntry $ensemble)
|
public function show(NominationEnsembleEntry $entry)
|
||||||
{
|
{
|
||||||
// TODO: Implement show() method.
|
// TODO: Implement show() method.
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +93,10 @@ class ScobdaNominationEnsembleEntryController extends Controller implements Nomi
|
||||||
}
|
}
|
||||||
|
|
||||||
$student = Student::find($validData['new_student']);
|
$student = Student::find($validData['new_student']);
|
||||||
|
if (auth()->user()->school_id !== $student->school_id) {
|
||||||
|
return redirect()->route('nomination.entry.index')->with('error',
|
||||||
|
'You may only nominate students from your school');
|
||||||
|
}
|
||||||
$nextRank = $this->collapseNominations($student->school, $proposedEnsemble, 'next');
|
$nextRank = $this->collapseNominations($student->school, $proposedEnsemble, 'next');
|
||||||
if ($nextRank > $proposedEnsemble->data['max_nominations']) {
|
if ($nextRank > $proposedEnsemble->data['max_nominations']) {
|
||||||
return redirect()->route('nomination.entry.index')->with('error',
|
return redirect()->route('nomination.entry.index')->with('error',
|
||||||
|
|
@ -111,19 +116,25 @@ class ScobdaNominationEnsembleEntryController extends Controller implements Nomi
|
||||||
'Nomination Recorded');
|
'Nomination Recorded');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(NominationEnsembleEntry $ensemble)
|
public function edit(NominationEnsembleEntry $entry)
|
||||||
{
|
{
|
||||||
// TODO: Implement edit() method.
|
// TODO: Implement edit() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(NominationEnsembleEntry $ensemble)
|
public function update(NominationEnsembleEntry $entry)
|
||||||
{
|
{
|
||||||
// TODO: Implement update() method.
|
// TODO: Implement update() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(NominationEnsembleEntry $ensemble)
|
public function destroy(NominationEnsembleEntry $entry)
|
||||||
{
|
{
|
||||||
// TODO: Implement destroy() method.
|
if ($entry->student->school_id !== auth()->user()->school_id) {
|
||||||
|
return redirect()->route('nomination.entry.index')->with('error',
|
||||||
|
'You may only delete nominations from your school');
|
||||||
|
}
|
||||||
|
$entry->delete();
|
||||||
|
|
||||||
|
return redirect()->route('nomination.entry.index')->with('success', 'Nomination Deleted');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,21 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<x-table.body>
|
<x-table.body>
|
||||||
|
{{-- List existing nominations--}}
|
||||||
@foreach($nominatedStudents[$ensemble->id] as $nomination)
|
@foreach($nominatedStudents[$ensemble->id] as $nomination)
|
||||||
<tr>
|
<tr>
|
||||||
<x-table.td>{{ $nomination->data['rank'] }}</x-table.td>
|
<x-table.td>{{ $nomination->data['rank'] }}</x-table.td>
|
||||||
<x-table.td>{{ $nomination->student->full_name() }}</x-table.td>
|
<x-table.td>{{ $nomination->student->full_name() }}</x-table.td>
|
||||||
<x-table.td>{{ $nomination->data['instrument'] }}</x-table.td>
|
<x-table.td>{{ $nomination->data['instrument'] }}</x-table.td>
|
||||||
|
<x-table.td>
|
||||||
|
<x-delete-resource-modal
|
||||||
|
title="Delete Nomination"
|
||||||
|
method="DELETE"
|
||||||
|
action="{{ route('nomination.entry.destroy', [$nomination]) }}">
|
||||||
|
Confirm you wish to delete the nomination of {{ $nomination->student->full_name() }}<br>
|
||||||
|
for the {{ $ensemble->name }} ensemble.
|
||||||
|
</x-delete-resource-modal>
|
||||||
|
</x-table.td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,6 @@ Route::middleware(['auth', 'verified'])->prefix('nominations/')->group(function
|
||||||
Route::controller(NominationEnsembleEntryController::class)->group(function () {
|
Route::controller(NominationEnsembleEntryController::class)->group(function () {
|
||||||
Route::get('/', 'index')->name('nomination.entry.index');
|
Route::get('/', 'index')->name('nomination.entry.index');
|
||||||
Route::post('/', 'store')->name('nomination.entry.store');
|
Route::post('/', 'store')->name('nomination.entry.store');
|
||||||
|
Route::delete('/{entry}', 'destroy')->name('nomination.entry.destroy');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue