Laravel foreach in form takes only last row

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)
                                <input type="text" name="id" value="{{$item->id}}">
                                <input type="text" name="name" value="{{$item->product_name}}">

                                <input type="text" name="price" value="{{$item->product_price}}">
                                <input type="submit" value="edit">


public function editsubmit(Request $req) {


        return redirect('/admin');

210 thoughts on “Laravel foreach in form takes only last row”

Leave a Comment