If you really want to do this all in one go you can name the inputs in array form as a container for all the records, something like records[1][product_name]
:
<form ...>
@csrf
@foreach ($Voorgerecht as $item)
<tr>
...
<td>
<input type="text" name="records[{{ $item->id }}][product_name]" value="...">
</td>
<td>
<input type="text" name="records[{{ $item->id }}][product_price]" value="{{ $item->product_price }}">
</td>
...
</tr>
@endforeach
</form>
Then in the Controller
... do validation ...
foreach ($request->input('records', []) as $id => $record) {
Model::findOrFail($id)->update($record);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…