I'm trying to create a shopping cart and I want to POST multiples fields with same name and process them
<?php foreach($datacart as $datacart) { ?>
<form method="post" action="/update-cart">
<input type="hidden" name="rowid" value="{{$datacart->rowid}}">
<input type="text" name="quantity" value="{{$datacart->quantity}}">
<?php }>
<input type="submit" value="update">
</form>
public function update_cart(request $request){
$rowId = $request->rowid;
$quantity = $request->quantity;
Cart::update($rowId, $quantity);
}
First displaying all products using a foreach. Then each item has a hidden rowid and a quantity.
Below code is showing my controller. But with this code, it only updates one item (lastone). But I want to update each product's quantity separately
Forgot to mention, I use https://github.com/Crinsane/LaravelShoppingcart as my cart plugin