Undefined variable: user Values are not updating..
ProfilesController.php file....
public function edit(User $user)
{
return view('profiles.edit',compact('user'));
}
public function update()
{
$data= request()->validate([
'title' =>'required',
'description'=>'required',
'url'=>'url',
'image'=>'',
]);
$user->profile->update($data);
return redirect("/profile/{$user->id}");
}
web.php file......
Route::get('/profile/{user}/edit', 'ProfilesController@edit')->name('profile.edit');
Route::patch('/profile/{user}', 'ProfilesController@update')->name('profile.update');
You are not accepting the User
within the update
method for route model binding, like you are on the other endpoints. Try changing your update method from
public function update()
to
public function update(User $user)