gpt4 book ai didi

php - 用户不更新 Laravel

转载 作者:行者123 更新时间:2023-11-29 05:07:23 26 4
gpt4 key购买 nike

更新方法:

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);

enter image description here

dd($request->birth.'---'.$request->sex.'---'.$request->about); 下面显示正确的输入

enter image description here

为什么不能正常工作?

最佳答案

根据 documentation

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com