0

コントローラ

 public function getScore(Request $request, $id)
{
   // $scores = Criteria::find($id);
    $contestants = Contestant::find($id);
    foreach ($request->criteria as $id => $criteria){
        $criteriaModel = Score::find($id);

        $scores = new Score();
        $scores->judge_name = $request->input('judge_name');
        $scores->contestant =  $contestants->name;
        $scores->criteria = $criteriaModel->criteria;
        $scores->score = $scores->score;
        $scores->save();
    }
    return redirect('/tabulation')->with('status', 'Score saved!');
}

      @foreach ($criterias as $criteria)
                                       <div class="form-group col-md-6">
                                           <label for="{{$criteria->name}}">{{$criteria->name}} </br> (0 - {{$criteria->points}})</label>
                                           <input type="text" name="criteria[{{$criteria->id}}][criteria]" value="{{$criteria->name}}" hidden>
                                           <input type="text" name="score[{{$criteria->id}}][score]" class="form-control" placeholder="Input score" required>
                                       </div>
                                   @endforeach
4

2 に答える 2