Skip to content

Cannot fill a models attributes when using $guarded #33939

Closed
@ImJacobChen

Description

@ImJacobChen
  • Laravel Version: 7.25.0
  • PHP Version: 7.4.8
  • Database Driver & Version: SQLite & MySQL 8 (although this is non database related I believe)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions