I have a route which has two parameters.
Route::delete('/org/{org-id}/delete/user/{user-id}', 'AppHttpControllersOrganizationController@deleteUserFromOrg')
->name('delete-user-from-org');
i call it in view
<td><a href="{{route('delete-user-from-org', ['org-id'=>$data->id, 'user-id' => $el->id ])}}"><button class="btn btn-danger">Удалить</button></a></td>
i think this should work because it substitutes the data correctly and redirects to the page http://localhost:8000/org/11/delete/user/2. REturn 404 error.
It’s does not see the controller, I tried some function in the route itself, this does not work either.
2
Answers
Route params should consist of alphabetic characters or _
Please fix your route params name
For example:
And your view blade
look at the
Route::delete()
part. In order to invoke that route i.e.delete-user-from-org
, you will require a DELETE request method (or create a form with a hidden input via@method('delete')
When you create a link with <a></a>, the request will be a GET (by default unless manipulated by js) which is why you are getting a 404 Not Found Error. You have two solutions.
First Solution (via form):
Second solution (via ajax):
Third Solution (change the method): Not recommended. Avoid it.
from Route::delete() to Route::get()