Examples of Mutators (3)

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.

Repository: realodix/urlhub (Github)
★ 242 Created: Aug 2018 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Models/Url.php
- app/Services/UrlService.php
Repository: academico-sis/academico (Github)
★ 45 Created: Dec 2018 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/Models/Invoice.php
- app/Http/Controllers/InvoiceController.php
Repository: JuanDMeGon/Laravel-from-Scratch (Github)
★ 11 Created: Apr 2020 Updated: Mar 2021 Laravel version: 8
Files in the example:
- app/User.php

Additional resources on mutators: