I need to pass an array to a controller. I made the form below but I get the error:
Missing required parameters for [Route: site.add.cart] [URI: adiciona-carrinho/{product}/{option}]. (View: /var/www/html/ecommerce/resources/views/site/pages/product/product.blade.php)
View:
<div class="col-12 offset-lg-6">
@php
$array = [1, 2];
@endphp
<a id="add-cart" href="{{ route('site.add.cart', ['product' => $product, 'option' => serialize($array)]) }}" class="btn btn-primary mt-5">Adicionar ao Carrinho</a>
</div>
Route:
Route::get('/adiciona-carrinho/{product}/{option}', 'CartController@addCart')->name('site.add.cart');
Controller
public function addCart(Product $product, $option)
{
dd($option);
}