samedi 31 août 2019

The route cant get the id from the form (Missing required parameters for [Route: update_user])

When i go to the page:blog.local/user/1 it returns this error:

Missing required parameters for [Route: update_user] [URI: user/{user}/update]. (View: C:\xampp\htdocs\blog\resources\views\login_pages\user.blade.php)

This is the view user.blade.php:

<h2 class="mypositionclass" > welcome user: </h2>
<hr>

<div style="text-align: center" >
    
    <div>
        <br>
        
    </div>
    <div>
        <br>
        
    </div>
    <div>
        <br>
        
    </div>
    <div>
        <br>
        
    </div>
    <div>
        <br><br>
        
    </div>
</div>

This is the route:

Route::post('/user/{user}/update', 'Login_pageController@update')->name('update_user');

This is the function update() from Login_pageController.php:

public function update(Request $request, $id)
{
    $request::validate([
        'name'=>'required',
        'surname'=>'required',
        'email'=>'required',
        'password'=>'required'
    ]);

    $user=User::findOrFail($id);
    $user->name= $request->name;
    $user->surname= $request->surname;
    $user->email= $request->email;
    $user->password= $request->password;
    $user->save();
    return view('login_pages.login_page');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire