Eloquent: Mutators
Introduction
Accessors & Mutators Defining An Accessor Defining A Mutator Date Mutators
Attribute Casting Array & JSON Casting
Introduction
Accessors and mutators allow you to format Eloquent attribute values when you retrieve or set them on model instances. For example, you may want to use the Laravel encrypter to encrypt a value while it is stored in the database, and then automatically decrypt the attribute when you access it on an Eloquent model.
In addition