[英]ErrorException (E_NOTICE) Undefined variable: user
Undefined variable: user Values are not updating..未定义变量:用户值未更新..
ProfilesController.php file.... ProfilesController.php 文件....
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...... web.php文件......
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.您没有在路由模型绑定的
update
方法中接受User
,就像您在其他端点上一样。 Try changing your update method from尝试更改您的更新方法
public function update()
to到
public function update(User $user)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.