Php Laravel 6.0购物车软件包:缺少[Route:Cart.update][URI:{rowId}]所需的参数

Php Laravel 6.0购物车软件包:缺少[Route:Cart.update][URI:{rowId}]所需的参数,php,laravel,e-commerce,cart,laravel-blade,Php,Laravel,E Commerce,Cart,Laravel Blade,我有两种方法。增加购物车中产品的数量。另一个减少了数量 {{-- INCREASE PRODUCT QUANTITY --}} <form action="{{ route('cart.store') }}" method="POST"> @csrf <input name="id" type="hidden" value="{{ $product->id }}"> <input name="na

我有两种方法。增加购物车中产品的数量。另一个减少了数量

{{-- INCREASE PRODUCT QUANTITY --}}
      <form action="{{ route('cart.store') }}" method="POST">
        @csrf 
        <input name="id" type="hidden" value="{{ $product->id }}"> 
        <input name="name" type="hidden" value="{{ $product->name }}"> 
        <input name="price" type="hidden" value="{{ $product->price }}"> 
        <button class="bg-success text-white" style="width: 2rem;"><strong>+</strong></button>
      </form>
      {{-- END INCREASE PRODUCT QUANTITY --}}

      {{-- DECREASE PRODUCT QUANTITY --}}
      <form action="{{ route('cart.update', $product->rowId) }}" method="POST">
        @csrf
        @method('PATCH')
        <button class="bg-danger text-white" style="width: 2rem;"><strong>-</strong></button>
      </form>
      {{-- END DECREASE PRODUCT QUANTITY --}}
增加数量的方法按预期工作(cart.store)。但是,当调用减少数量的方法(cart.update)时,我得到以下结果:

Missing required parameters for [Route: cart.update] [URI: {rowId}].
熟悉这个软件包的人知道这里发生了什么吗


谢谢

问题在这里
action=“{{route('cart.update')}}”
,您需要通过action route传递一个参数。比如:
action=“{route('cart.update',$product->id)}}”

另外,我认为您需要修改更新函数,在$rowId add type之前,意味着添加产品型号名称。我已经做了您建议的更改,但仍然得到相同的错误。请参见上文。它不是$product->rowId,请用$product->id替换它。更正一个:
我更改了它,现在我得到了一个错误:
数组\u key\u exists():第一个参数应该是字符串或整数。在我的另一个带有这个购物车包的项目中,我必须使用rowId而不是id。为什么现在会有所不同?感谢您必须传递产品的属性,该属性是id,因此您需要传递$product->id。最后,替换
$product=Cart::get($rowId)带有
$product=Cart::get($rowId->id)
// increases product quantity in the cart
Route::post('/', 'CartController@store')->name('cart.store');

// decreases product quantity in the cart
Route::patch('/{rowId}', 'CartController@update')->name('cart.update'); 
Missing required parameters for [Route: cart.update] [URI: {rowId}].