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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners