I am new to Laravel and I am trying to update an item quantity in a cart, so I set this route:
Route::patch('/item/{rowId}', [CartController::class, 'update'])->name('item.update');
and my form code is like this:
<form action="{{ route('item-update', $items->rowId)}}" method="PUT">
@method('PUT')
@csrf
<span>
<button type="submit"><span style="color:blue">
Mettre à jour le panier</span></button>
</span>
</form>
I tried everything, but still can't get to the update method in my controller:
public function update(Request $request, $rowId)
{
//
}
What am I doing wrong?
Route::patch
and method="PUT"
is not wrong.
But Route::patch
and method="POST"
is accepted practice.
Real issue in here is route names are not match ...->name('item.update');
and {{ route('item-update',...
change route('item-update')
to route('item.update')