Allow the modification of Bonus Score definition data.
Closes #100 Closes #58
This commit is contained in:
parent
6ca05bf4d5
commit
1acb286ac8
|
|
@ -37,6 +37,20 @@ class BonusScoreDefinitionController extends Controller
|
||||||
return to_route('admin.bonus-scores.index')->with('success', 'Bonus Score Created');
|
return to_route('admin.bonus-scores.index')->with('success', 'Bonus Score Created');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update(BonusScoreDefinition $bonusScore)
|
||||||
|
{
|
||||||
|
$validData = request()->validate([
|
||||||
|
'name' => 'required|unique:bonus_score_definitions,name,'.$bonusScore->id,
|
||||||
|
'max_score' => 'required|numeric',
|
||||||
|
'weight' => 'required|numeric',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$bonusScore->update($validData);
|
||||||
|
|
||||||
|
return to_route('admin.bonus-scores.index')->with('success', 'Bonus Score Updated');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function destroy(BonusScoreDefinition $bonusScore)
|
public function destroy(BonusScoreDefinition $bonusScore)
|
||||||
{
|
{
|
||||||
if ($bonusScore->auditions()->count() > 0) {
|
if ($bonusScore->auditions()->count() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<x-modal-body show-var="showEditBonusScoreModal{{ $bonusScoreModalId }}">
|
||||||
|
<x-slot:title>
|
||||||
|
Edit Bonus Score
|
||||||
|
</x-slot:title>
|
||||||
|
<x-form.form id="update-bonus-score-form" action="{{ route('admin.bonus-scores.update', $bonusScore) }}" method="PATCH">
|
||||||
|
<x-form.body-grid columns="12">
|
||||||
|
<x-form.field name="name" label_text="Name" colspan="8" value="{{ $bonusScore->name }}" />
|
||||||
|
<x-form.field name="max_score" type="number" label_text="Max Points" colspan="2" value="{{ $bonusScore->max_score }}" />
|
||||||
|
<x-form.field name="weight" label_text="Weight" colspan="2" value="{{ $bonusScore->weight }}" />
|
||||||
|
<div class="col-start-9 col-span-4 row-start-2">
|
||||||
|
<x-form.button >Update Bonus Score</x-form.button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</x-form.body-grid>
|
||||||
|
</x-form.form>
|
||||||
|
</x-modal-body>
|
||||||
|
|
@ -8,10 +8,11 @@
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@foreach($bonusScores as $bonusScore)
|
@foreach($bonusScores as $bonusScore)
|
||||||
<x-card.card class="mx-auto max-w-xl mb-5">
|
<x-card.card class="mx-auto max-w-xl mb-5" x-data="{ showEditBonusScoreModal{{$bonusScore->id}}: false }">
|
||||||
<x-card.heading>
|
<x-card.heading>
|
||||||
|
@php($bonusScoreModalId = $bonusScore->id)
|
||||||
{{ $bonusScore->name }}
|
@include('admin.bonus-scores.index-edit-bonus-score-modal')
|
||||||
|
{{ $bonusScore->name }} <button class="text-sm font-normal" x-on:click="showEditBonusScoreModal{{$bonusScore->id}}=true">[Edit]</button>
|
||||||
<x-slot:subheading>
|
<x-slot:subheading>
|
||||||
Max Points: {{ $bonusScore->max_score }} | Weight: {{ $bonusScore->weight }}
|
Max Points: {{ $bonusScore->max_score }} | Weight: {{ $bonusScore->weight }}
|
||||||
</x-slot:subheading>
|
</x-slot:subheading>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
Route::get('/judges', 'judges')->name('admin.bonus-scores.judges');
|
Route::get('/judges', 'judges')->name('admin.bonus-scores.judges');
|
||||||
Route::delete('{bonusScore}/judges/', 'removeJudge')->name('admin.bonus-scores.judges.remove');
|
Route::delete('{bonusScore}/judges/', 'removeJudge')->name('admin.bonus-scores.judges.remove');
|
||||||
Route::post('{bonusScore}/judges/', 'assignJudge')->name('admin.bonus-scores.judges.assign');
|
Route::post('{bonusScore}/judges/', 'assignJudge')->name('admin.bonus-scores.judges.assign');
|
||||||
|
Route::patch('/{bonusScore}', 'update')->name('admin.bonus-scores.update');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue