Updating user gives 404 error Hi I got a form that looks like this (fields are removed).
<form action="{{ route('users.update', Auth::user()->id) }}" method="POST">
{{ csrf_field() }}
{{ method_field('PATCH') }}
</form>
And a route that looks like this:
Route::patch('/users/{$id}', 'UserController@update')->name('users.update');
However, when I submit the form, I get a 404 error. Even though the controller method called update is suposed to return the request.
What am I missing?
Your URI wildcard should not have a $ symbol:
Route::patch('/users/{id}', 'UserController@update')->name('users.update');
Personally, I wouldn't have the authenticated user's id in the route if only the authenticated user can/should be updated. You can get access to the authenticated user in the controller's update method anyway.
Thanks.
Yes I agree, that is what I used to have but now I want to give an admin access to updating other users, so that no longer works.
Please sign in or create an account to participate in this conversation.