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

artisticre's avatar

Too Few Arguments

I am getting this error but cannot figure out why

Too few arguments to function App\Http\Controllers\ProfilesController::update(), 1 passed and exactly 2 expected

public function update(Request $request, $id)
    {
        $this->validate($request, [
            'name' => 'required'
            
        ]);
        $user = User::find($id);
         // Handle File Upload
        
        // Update Post
        $user->name = $request->input('name');
         
        $user->save();
        return redirect('profile.profile')->with('success', 'Profile Updated');
    }
0 likes
6 replies
Sergiu17's avatar

Your route does not have wild card

// wrong
Route::put('/profile',ProfilesController@update')
// correct 
Route::put('/profile/{id}', 'ProfilesController@update');
ahmeddabak's avatar
  • Make sure that you have imported the right Request class with this use statement use Illuminate\Http\Request;.
  • if your are not using a resource controller, make sure that your route difinition in web.php expect a parameter Route::post('/profile/{id}','ProfilesController@update');
artisticre's avatar

I did this and got Missing required parameters for [Route: update] [URI: profile/{id}].

Route::put('/profile/{id}', 'ProfilesController@update')->name('update');

Sergiu17's avatar
Sergiu17
Best Answer
Level 60

@artisticre now when you send the request, make sure you include the ID

<form action="/profile/{{ $user-> id }}"

or

// instead of
$user = User::find($id);
// use
$user = auth()->user()
artisticre's avatar

I am using that Request and using using Resource Controller

Sergiu17's avatar

@ahmeddabak if you used $user = auth()->user(), then you could remove $id from your update method

Route::put('/profile', 'ProfilesController@update')

public function update(Request $request)
{
    $user = auth()->user();

    // ...
}

Please or to participate in this conversation.