在Laravel 5.5中保存同名属性的方法是什么?如果我正在将它们分配到foreach循环中以及放置save方法的位置,我不是。
<input type="text" name="aka" value="The Magnificent" />
@foreach ($listTalkOperationTime as $data)
<input type="number" name="startHours[]"value="{{ $data->starthour }}" />
<input type="number" name="startMins[]" value="{{ $data->startmin }}" />
<input type="number" name="endHours[]" value="{{ $data->endhour }}" />
<input type="number" name="endMins[]" value="{{ $data->endmin }}" />
<button type="button">Submit</button>
@endforeach
这就是我的想法
$model = new User;
$model->aka = $request->aka;
foreach ($request->startHours as $so) {
$model->starthours = $so;
}
foreach ($request->startMins $sm) {
$model->starthours = $sm;
}
...
$model->save()