Category: Laravel, PHP

Please consider supporting us by just disabling your AD BLOCKER and reloading this page again. Accessors and mutators allow you to modify Eloquent attribute values when you fetch or set them on model instances. For Eg: If you would like to transform or manipulate data before storing or while fetching from the database tables than you can you Mutators and Accessors respectively.

To define a mutator, define a setFooAttribute method on your model where Foo is the "studly"(meaning every word first letter will be capital, Eg: first_name of table column will become FirstName) cased name of the column you wish to write. Eg: I want to add a mutator to lowercase the first_name column of my table while storing to table then we need to create setFirstNameAttribute() method in our model.
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