Skip to main content

Code Examples of mutators

Discover how to use Laravel's mutators method in real-world applications. Browse 3 examples from popular open-source projects.

3 examples
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.

realodix/urlhub

  • 537
  • Created Aug 2018
  • Updated May 2026

Files in this example

  • app/Models/Url.php
    • app/Services/UrlService.php
View full example

academico-sis/academico

  • 371
  • Created Dec 2018
  • Updated Jun 2026

Files in this example

  • app/Models/Invoice.php
    • app/Http/Controllers/InvoiceController.php
View full example

JuanDMeGon/Laravel-from-Scratch

  • 18
  • Created Apr 2020
  • Updated Mar 2021

Files in this example

  • app/User.php
View full example