I am trying to delete an object without using forms. So what I did was improvising. I've made a route:
Route::get('category/destroyMe', ['uses' => 'CategoryController@destroyMe', 'as' => 'category.destroyMe']);
And in the view I am picking up the category id like so:
<a href="{{route('category.destroyMe', ['id' => $category->id])}}" ></a>
And finally the controller:
public function destroyMe()
{
$this->destroy(Category::find(Input::get('id')));
return redirect()->back();
}
Question:
I was wondering if there is a way to do this without my helper method destroyMe()
? Is there a way to forward a method = 'DELETE'
via href or something, so i can call my resource route like category.destroy
without the need of complication?
EDIT: I don't want to do it with forms (as I do know how to do it like that). Nor do I want to complicate with ajax or some extra scripts or something. I am wondering if there is a pure Laravel slick solution like
<a href="{{route('category.destroy', ['id' => $category->id, 'method' => 'DELETE])}}" ></a>