diff --git a/app/Http/Controllers/NominationEnsembles/ScobdaNominationEnsembleEntryController.php b/app/Http/Controllers/NominationEnsembles/ScobdaNominationEnsembleEntryController.php
index 33b6f50..83aaf40 100644
--- a/app/Http/Controllers/NominationEnsembles/ScobdaNominationEnsembleEntryController.php
+++ b/app/Http/Controllers/NominationEnsembles/ScobdaNominationEnsembleEntryController.php
@@ -147,7 +147,7 @@ class ScobdaNominationEnsembleEntryController extends Controller implements Nomi
*
* @var returnType = next|nominations
*/
- private function collapseNominations(School $school, NominationEnsemble $ensemble, $returnType)
+ private function collapseNominations(School $school, NominationEnsemble $ensemble, $returnType = 'next')
{
$nominations = $school->nominations()->get()->where('nomination_ensemble_id',
$ensemble->id)->sortBy('data.rank');
@@ -163,4 +163,28 @@ class ScobdaNominationEnsembleEntryController extends Controller implements Nomi
return $nominations;
}
+
+ public function move()
+ {
+
+ // TODO: Verify the student being moved is from the users school
+ $validData = request()->validate([
+ 'direction' => 'required|in:up,down',
+ 'nominationId' => 'required|exists:App\Models\NominationEnsembleEntry,id',
+ ]);
+ $direction = $validData['direction'];
+ $nomination = NominationEnsembleEntry::findOrFail($validData['nominationId']);
+ $data = $nomination->data;
+ if ($validData['direction'] == 'up') {
+ $data['rank'] = $nomination->data['rank'] - 1.5;
+ }
+ if ($validData['direction'] == 'down') {
+ $data['rank'] = $nomination->data['rank'] + 1.5;
+ }
+ $nomination->update(['data' => $data]);
+ $this->collapseNominations($nomination->student->school, $nomination->ensemble, 'next');
+
+ return redirect()->route('nomination.entry.index')->with('success', 'Nomination Moved');
+
+ }
}
diff --git a/app/Models/NominationEnsembleEntry.php b/app/Models/NominationEnsembleEntry.php
index f6ac68f..a5ba469 100644
--- a/app/Models/NominationEnsembleEntry.php
+++ b/app/Models/NominationEnsembleEntry.php
@@ -21,7 +21,7 @@ class NominationEnsembleEntry extends Model
protected function ensemble(): BelongsTo
{
- return $this->belongsTo(NominationEnsemble::class);
+ return $this->belongsTo(NominationEnsemble::class, 'nomination_ensemble_id');
}
protected function student(): BelongsTo
diff --git a/resources/views/components/icons/down-arrow.blade.php b/resources/views/components/icons/down-arrow.blade.php
new file mode 100644
index 0000000..820107b
--- /dev/null
+++ b/resources/views/components/icons/down-arrow.blade.php
@@ -0,0 +1,3 @@
+
diff --git a/resources/views/components/icons/up-arrow.blade.php b/resources/views/components/icons/up-arrow.blade.php
new file mode 100644
index 0000000..7867615
--- /dev/null
+++ b/resources/views/components/icons/up-arrow.blade.php
@@ -0,0 +1,3 @@
+
diff --git a/resources/views/nomination_ensembles/scobda/entries/index.blade.php b/resources/views/nomination_ensembles/scobda/entries/index.blade.php
index c486156..ad9020b 100644
--- a/resources/views/nomination_ensembles/scobda/entries/index.blade.php
+++ b/resources/views/nomination_ensembles/scobda/entries/index.blade.php
@@ -23,7 +23,7 @@
{{ $nomination->data['rank'] }}
{{ $nomination->student->full_name() }}
{{ $nomination->data['instrument'] }}
-
+
student->full_name() }}
for the {{ $ensemble->name }} ensemble.
+
+
@endforeach
diff --git a/routes/nominationEnsemble.php b/routes/nominationEnsemble.php
index de35017..66a1acf 100644
--- a/routes/nominationEnsemble.php
+++ b/routes/nominationEnsemble.php
@@ -19,5 +19,6 @@ Route::middleware(['auth', 'verified'])->prefix('nominations/')->group(function
Route::get('/', 'index')->name('nomination.entry.index');
Route::post('/', 'store')->name('nomination.entry.store');
Route::delete('/{entry}', 'destroy')->name('nomination.entry.destroy');
+ Route::post('/move', 'move')->name('nomination.entry.move');
});
});