I am working on a Laravel project (v 5.4) and I have done CRUD for category management. Currently I can create a new category and I could delete.
I created a view (with a blade) to remove 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="{{ url('/categories', ['id' => $category->id]) }}">
<button class="btn btn-default">
Delete
</button>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
And in the web.php routing file, I wrote:
Route::delete('/categories/{id}', CategoryController@destroy);
I have a CategoryController with a kill () method that removes a category and redirects to a list of categories. But when I click the button to delete, I get an error message explaining that this route is not defined. If I replace Route::deletewith Route::get, it works. I think url is being called with GET, but I would save this for another action.
I tried to replace the link with the form and "DELETE" as the value of the attribute "method", but it does not work.
url DELETE, Route::delete?
.