Reputation: 15
As you can see here I am looping with foreach but it only sends the one product_name (last one) of the cart, but I Want to send every product_name.
<form method="POST" action="{{route('order.store')}}">
@csrf
@method('POST')
@foreach(Cart::content() as $item)
<input type="hidden" name="product_name" value="{{$item->name}}">
@endforeach
</form>
Upvotes: 0
Views: 48
Reputation: 5270
You have to use like input
name as array
<input type="hidden" name="product_name[]" value="{{$item->name}}">
Upvotes: 1
Reputation: 6233
you have to use an array to send multiple values using the same name attribute.
@foreach(Cart::content() as $item)
<input type="hidden" name="product_name[]" value="{{$item->name}}">
@endforeach
this will send each product name and you have to loop through to get every one in the backend.
Upvotes: 0