Laravel Eloquent - $fillable is not working?

后端 未结 4 759
天涯浪人
天涯浪人 2020-12-11 09:28

I have set the variable $fillable in my model. I wanted to test the update functionality, and I get this error:

SQLSTATE[42S

4条回答
  •  -上瘾入骨i
    2020-12-11 10:05

    I experienced this breaking after updating from Laravel 5.2 to 5.4 - I can't find anything in the documentation / migration guide that covers it.

    As covered in this github issue the correct fix/use of Eloquent seems to be:

    Positions::find($id)->fill(Input::all())->save();
    

    To trigger the fillable check by laravel and then perist the changes.

提交回复
热议问题