Laravel 5.1: привязка модели формы — переключатели

Сценарий:

Я хочу создать что-то похожее на вопросник, чтобы у меня было несколько форм на одной странице, каждая из которых связана с вопросом, и имеет собственную кнопку отправки, на каждый вопрос есть 4 ответа, поэтому пользователь может выбрать только один ответ на вопрос с помощью переключателей.
Мне нужно привязать данные к связанному полю, используя привязку данных формы, все остальные данные привязываются идеально, но проблема в переключателе.

контроллер

/* get all answers that related to the topic */
$question_answers = ['criteria_id' => $criteriaId, 'sector_id' => $sector_id];
$answers = Answer::where($question_answers)->get();
$questions = $criteria->question()->get();
/* check existing data */
$check_data = ['organisation_id' => $organisation_id, 'customize_criteria_id' => $criteriaId];
$exist_data = RatingDatum::where($check_data)->get();

Посмотреть:

 @foreach($question as $index=>$question)
<div class="plan bg-plan">
<h5>{{$question->question}}</h5>
<hr>
@foreach($exist_data as $datum)
@if($datum->question_id == $question->id)
{!! Form::model($datum,['method' => 'PATCH','action'=>['RatingDataController@update'],$datum->id]) !!}
@endif
@endforeach
@foreach($answers as $answer)
@if($answer->question_id == $question->id)
<div class="radio">
<label>

{!! Form::radio('answer_id['.$index.']', $answer->id, $datum->answer_id != null ? 'true' : 'false')!!}
{{$answer->score}} {{$answer->answer}}
</label>
</div>
@endif
@endforeach
<div class="form-group">
{!! Form::label('comment','Comment :') !!}
{!! Form::textarea('comment' ,null,['class'=>'form-control', 'rows' => 4]) !!}

{!! Form::label('reference','Reference:') !!}
{!! Form::textarea('reference',null,['class'=>'form-control', 'rows' => 1]) !!}
</div>
{!! Form::submit('Submit Data', ['class' => 'btn btn-success submit']) !!}
{!! Form::close() !!}
<!--/.Plan -->
</div>

3

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …