Enable deletion of nominations by users
This commit is contained in:
parent
ac5c4cb53b
commit
d7da1d4b7f
|
|
@ -58,6 +58,9 @@ class MeobdaNominationEnsembleEntryController extends Controller implements Nomi
|
||||||
}
|
}
|
||||||
$availableStudents[$ensemble->id] = $students;
|
$availableStudents[$ensemble->id] = $students;
|
||||||
$nominationsAvailable[$ensemble->id] = $existingNominations[$ensemble->id]->count() < $ensemble->data['max_nominations'];
|
$nominationsAvailable[$ensemble->id] = $existingNominations[$ensemble->id]->count() < $ensemble->data['max_nominations'];
|
||||||
|
if ($currentDate > $ensemble->entry_deadline) {
|
||||||
|
$nominationsAvailable[$ensemble->id] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('nomination_ensembles.meobda.entries.index',
|
return view('nomination_ensembles.meobda.entries.index',
|
||||||
|
|
@ -167,6 +170,20 @@ class MeobdaNominationEnsembleEntryController extends Controller implements Nomi
|
||||||
|
|
||||||
public function destroy(NominationEnsembleEntry $entry)
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentDate = Carbon::now('America/Chicago');
|
||||||
|
$currentDate = $currentDate->format('Y-m-d');
|
||||||
|
if ($entry->ensemble->entry_deadline < $currentDate) {
|
||||||
|
return redirect()->route('nomination.entry.index')->with('error',
|
||||||
|
'You cannot delete nominations after the deadline');
|
||||||
|
}
|
||||||
|
|
||||||
|
$entry->delete();
|
||||||
|
|
||||||
|
return redirect()->route('nomination.entry.index')->with('success', 'Nomination Deleted');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,23 @@
|
||||||
<x-table.body>
|
<x-table.body>
|
||||||
@foreach($existingNominations[$ensemble->id] as $nom)
|
@foreach($existingNominations[$ensemble->id] as $nom)
|
||||||
<tr>
|
<tr>
|
||||||
<x-table.td>{{ $nom->student->full_name() }}</x-table.td>
|
<x-table.td class="flex">
|
||||||
|
{{ $nom->student->full_name() }}
|
||||||
|
</x-table.td>
|
||||||
<x-table.td>{{ $nom->student->grade }}</x-table.td>
|
<x-table.td>{{ $nom->student->grade }}</x-table.td>
|
||||||
<x-table.td>{{ $nom->data['instrument'] }}</x-table.td>
|
<x-table.td>{{ $nom->data['instrument'] }}</x-table.td>
|
||||||
|
@if($nominationsAvailable[$ensemble->id])
|
||||||
|
<x-table.td>
|
||||||
|
<x-delete-resource-modal
|
||||||
|
title="Delete Nomination"
|
||||||
|
method="DELETE"
|
||||||
|
action="{{ route('nomination.entry.destroy', [$nom]) }}">
|
||||||
|
Confirm you wish to delete the nomination
|
||||||
|
of {{ $nom->student->full_name() }}<br>
|
||||||
|
for the {{ $ensemble->name }} ensemble.
|
||||||
|
</x-delete-resource-modal>
|
||||||
|
</x-table.td>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-table.body>
|
</x-table.body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue