judgingAssignments; return view('judging.index', compact('rooms')); } public function auditionEntryList(Audition $audition) { // TODO verify user is assigned to judge this audition $entries = Entry::where('audition_id','=',$audition->id)->orderBy('draw_number')->with('audition')->get(); $subscores = $audition->scoringGuide->subscores()->orderBy('display_order')->get(); return view('judging.audition_entry_list', compact('audition','entries','subscores')); } public function entryScoreSheet(Entry $entry) { // TODO verify user is assigned to judge this audition return view('judging.entry_score_sheet',compact('entry')); } public function saveScoreSheet(Request $request, Entry $entry) { Gate::authorize('create',[ScoreSheet::class,$entry]); // TODO verify user is assigned to judge this audition $scoringGuide = $entry->audition->scoringGuide()->with('subscores')->first(); $scoreValidation = $scoringGuide->validateScores($request->input('score')); if ($scoreValidation != 'success') { return redirect(url()->previous())->with('error', $scoreValidation)->with('oldScores',$request->all()); } $scoreSheetArray = []; foreach($scoringGuide->subscores as $subscore) { $scoreSheetArray[$subscore->id] = [ 'score' => $request->input('score')[$subscore->id], 'subscore_id' => $subscore->id, 'subscore_name' => $subscore->name ]; } ScoreSheet::create([ 'user_id' => Auth::user()->id, 'entry_id' => $entry->id, 'subscores' => $scoreSheetArray ]); return redirect('/judging/audition/' . $entry->audition_id)->with('success','Entered scores for ' . $entry->audition->name . ' ' . $entry->draw_number); } }