Short information about mutators
You use Eloquent Mutators to transform the value before saving it into the database. Example: re-formatting the date to the correct format, hashing the password.
All you need to do is define the method in your Model: function setFieldAttribute($value) and do the transformations inside.
Read more in the official Laravel docs.
- app/Services/UrlService.php
- app/Http/Controllers/InvoiceController.php
Additional resources on mutators:
-
Povilas Korop | www.youtube.com
Published on
-
What are Mutators and Accessors in Laravel
Forum topic
stackoverflow.com
Published on