I am trying to update a restaurant menu via form. firstly I take all contents of the menu category and put them via foreach in a input value so they are all editable and pre setup for editing.
now the big problem is whenever I completely try to edit the form, it only edits the last row because that's the last received and thus ignoring the rest. How would I make the form submit all requested items from the foreach?
making a form for each item would be a big no no because then there would be an button for each row which hinders the productivity
Blade view:
<form action="test" method="head">
@foreach ($Voorgerecht as $item)
@csrf
<tr>
<td>
<input type="text" name="id" value="{{$item->id}}">
</td>
<td>
<input type="text" name="name" value="{{$item->product_name}}">
</td>
<td>
<input type="text" name="price" value="{{$item->product_price}}">
</td>
<td>
<input type="submit" value="edit">
</td>
@endforeach
</tr>
</form>
Controller:
public function editsubmit(Request $req) {
update::where('id',$req->id)
->update(['product_name'=>$req->name]);
return redirect('/admin');
}