Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jorisvanandel's avatar

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?

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

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.

1 like
jorisvanandel's avatar

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 or to participate in this conversation.