Kee Nops
Kee Nops

Reputation: 43

Laravel 5.7 delete does not reach controller delete method (returns 404 error page)

So i have this delete form

<form action="/remove-cart/{{ $item->rowId}}" method="POST">
   @method('DELETE')
   @csrf
   <input type="submit" value="Remove item">
 </form>

which goes to this route

 Route::delete('/remove-cart/{$id}', 'CartController@removeCart');

which is supposed to go to a method

public function removeCart($id){

  return $id;

}

but the method is not reached, i get a 404 page not found with url showing http://project.dev/remove-cart/123 (123 is the value of $item->rowId)

What am i doing wrong here?

Upvotes: 3

Views: 1328

Answers (1)

aleksejjj
aleksejjj

Reputation: 1835

Please try Route::delete('/remove-cart/{id}', 'CartController@removeCart'); instead {$id}

Upvotes: 3

Related Questions