I'm working on a Laravel (v 5.4) project and i did the CRUD to manage categories. Currently, i can create a new category and i would be able to delete.
I created the view (with blade) to delete the categories :
<table class="table">
<thead>
<th>Name</th>
<th>Action</th>
</thead>
<tbody>
@foreach ($categories as $category)
<tr>
<td>$category->name</td>
<td>
<a href="">
<button class="btn btn-default">
Delete
</button>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
And in the routing file web.php, i wrote :
Route::delete('/categories/{id}', CategoryController@destroy);
I have a controller CategoryController with a method destroy() who delete category and redirect to list of categories. But when i click on the button to delete, i get an error that explain this route is not define. If i replace Route::delete
with Route::get
it works. I think the url is called with GET but i would keep that for an other action.
I tried to replace the link with a form and "DELETE" as the value of "method" attribute but it didn't work.
How can i call url with DELETE method to catch it with Route::delete
?
Thanks in advance.
via Needlle