Enter and store no show #13

Merged
okorpheus merged 6 commits from enter-and-store-no-show into master 2024-07-08 04:32:28 +00:00
2 changed files with 31 additions and 15 deletions
Showing only changes of commit 87f091ee5b - Show all commits

View File

@ -7,15 +7,21 @@ use App\Models\Entry;
use App\Models\ScoreSheet; use App\Models\ScoreSheet;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
class ScoreController extends Controller class ScoreController extends Controller
{ {
public function chooseEntry(Request $request) public function chooseEntry(Request $request)
{ {
return view('tabulation.choose_entry'); $method = 'GET';
$formRoute = 'scores.entryScoreSheet';
return view('tabulation.choose_entry', compact('method', 'formRoute'));
} }
public function destroyScore(ScoreSheet $score) { public function destroyScore(ScoreSheet $score)
{
$score->delete(); $score->delete();
return redirect()->back()->with('success', 'Score Deleted'); return redirect()->back()->with('success', 'Score Deleted');
} }
@ -36,7 +42,9 @@ class ScoreController extends Controller
if (! $entry) { if (! $entry) {
return redirect()->route('tabulation.chooseEntry')->with('error', 'Entry not found'); return redirect()->route('tabulation.chooseEntry')->with('error', 'Entry not found');
} }
return view('tabulation.entry_score_sheet', compact('entry','judges','scoring_guide','subscores','existing_sheets'));
return view('tabulation.entry_score_sheet',
compact('entry', 'judges', 'scoring_guide', 'subscores', 'existing_sheets'));
} }
public function saveEntryScoreSheet(Request $request, Entry $entry) public function saveEntryScoreSheet(Request $request, Entry $entry)
@ -52,7 +60,8 @@ class ScoreController extends Controller
$scoreValidation = $scoringGuide->validateScores($request->input('judge'.$judge->id)); $scoreValidation = $scoringGuide->validateScores($request->input('judge'.$judge->id));
if ($scoreValidation != 'success') { if ($scoreValidation != 'success') {
return redirect(url()->previous())->with('error', $judge->full_name() . ': ' . $scoreValidation)->with('oldScores',$request->all()); return redirect(url()->previous())->with('error',
$judge->full_name().': '.$scoreValidation)->with('oldScores', $request->all());
} }
$scoreSubmission = $request->input('judge'.$judge->id); $scoreSubmission = $request->input('judge'.$judge->id);
@ -61,7 +70,7 @@ class ScoreController extends Controller
$scoresToSave[$subscore->id] = [ $scoresToSave[$subscore->id] = [
'subscore_id' => $subscore->id, 'subscore_id' => $subscore->id,
'subscore_name' => $subscore->name, 'subscore_name' => $subscore->name,
'score' => intval($scoreSubmission[$subscore->id]) 'score' => intval($scoreSubmission[$subscore->id]),
]; ];
} }
$preparedScoreSheets[$judge->id]['scores'] = $scoresToSave; $preparedScoreSheets[$judge->id]['scores'] = $scoresToSave;
@ -72,7 +81,7 @@ class ScoreController extends Controller
['subscores' => $sheet['scores']] ['subscores' => $sheet['scores']]
); );
} }
return redirect()->route('scores.chooseEntry')->with('success',count($preparedScoreSheets) . " Scores saved");
}
return redirect()->route('scores.chooseEntry')->with('success', count($preparedScoreSheets).' Scores saved');
}
} }

View File

@ -1,9 +1,16 @@
@php
/**
* @var string $method Method for the select form
* @var string $formRoute Route for the form action. Should be a route name
*/
@endphp
<x-layout.app> <x-layout.app>
<x-slot:page_title>Choose Entry</x-slot:page_title> <x-slot:page_title>Choose Entry</x-slot:page_title>
<x-card.card class="mx-auto max-w-sm"> <x-card.card class="mx-auto max-w-sm">
<x-card.heading>Choose Entry</x-card.heading> <x-card.heading>Choose Entry</x-card.heading>
<div class=""> <div class="">
<x-form.form method="GET" action="{{ route('scores.entryScoreSheet') }}" class="mb-4 mt-3"> <x-form.form method="{{ $method }}" action="{{ route($formRoute) }}" class="mb-4 mt-3">
<x-form.field name="entry_id" label_text="Entry ID"></x-form.field> <x-form.field name="entry_id" label_text="Entry ID"></x-form.field>
<x-form.footer > <x-form.footer >
<x-form.button>Select</x-form.button> <x-form.button>Select</x-form.button>