Category: Laravel, PHP, javascript

While it’s not recommended to allow all of your model’s attributes mass assignable since in that case you need to make sure to hand-craft the arrays passed to Eloquent’s fill, create, and update methods. But there might be some instances where you may want to consider unguarding all of the attributes. The de-facto way of unguarding a single model is to set an empty array to the $guarded property like so. But what if you want to make all of your models as mass assignable all at once?

Well, to do that, you need to use the unguard() method on the Illuminate\Database\Eloquent\Model class.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners