I'm new in Laravel!!
I have a js that send a request DELETE to my controller:
$.ajax({
url: link,
method: 'DELETE',
data: {
_token: $('input#_token').val(),
},
Than my controller return redirect
public function destroy(User $user)
{
$this->repository->delete($user->id);
return redirect()->to(route('users.index'));
}
This route "users.index" has the "GET" method, but the redirect is considering the DELETE method, resulting in this error:
DELETE http://localhost:8000/users 405 (Method Not Allowed)
Can i change the method using in redirect?
Tks!