You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
regarding to this pr #33777 you have to make sure that you fill an actual column
if column is not found in the table it will be treated as guarded and you can not set it
I've found that this doesn't work with unit testing, and also interferes with integration tests when run in the same test suite as a unit test that tries to do this. I've proposed a fix at #39880. My workaround is to Model::unguard() everything during TestCase::setUp(), however I'd prefer to not have to do that.
Description:
During tests I create a
new Model(['attr' => 'val'])
for example with$guarded = ['id']
.When I inspect the model via
dd($model->toArray())
the attributes that I set are not there.If I set
$fillable = ['attr']
on the model then the attributes I set will be shown.This only starting happening for me a few days ago
Steps To Reproduce:
I created a repo containing a demo demonstrating this behaviour. You can find the steps in the README.
https://github.com/ImJacobChen/laravel-model-guarded-bug
The text was updated successfully, but these errors were encountered: