I want a user to delete a product when he clicks unlike button but I'm getting an error 404 url not found, but I have the url.
If I put dd($product) before $like = Like::findOrFail($product); it displays the id(4) but if I put dd($like), then it throws an error 404. How can I make this function work?.
Controller
 public function destroy($product)
 {
   $like = Like::findOrFail($product);
     dd($like);
   $like->delete();
  return 'done';
 }
Blade
  <a class="remove"  href="" > Unlike </a>
Route
 Route::get('product/{product}/unlike', ['as' => 'product.unlike', 'uses' => 'LikeController@destroy']);
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire