更新方法:
public function update(UserUpdateRequest $request, Users $uzytkownik)
{
$this->authorize('update', $uzytkownik);
if ( $uzytkownik->update([
'birth' => $request->birth,
'sex' => $request->sex,
'about' => $request->about,
]) )
{
return 1;
}
return 0;
}
在此处更新页面 1
出现。就像它做的那样。
但是在 db 中什么都没有改变。
$uzytkownik
是正确的用户,并且
这是 dd($uzytkownik);
在 dd($request->birth.'---'.$request->sex.'---'.$request->about);
下面显示正确的输入
为什么不能正常工作?
最佳答案
Mass Assignment You may also use the create method to save a new model in a single line. The inserted model instance will be returned to you from the method. However, before doing so, you will need to specify either a fillable or guarded attribute on the model, as all Eloquent models protect against mass-assignment by default.
您需要确保 $fillable
或 $guarded
设置正确,否则更改可能不会持久。
关于php - 用户不更新 Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45483099/