Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

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

  • 532
  • Created Aug 2018
  • Updated Nov 2025

Files in this example

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

academico-sis/academico

  • 338
  • Created Dec 2018
  • Updated Nov 2025

Files in this example

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

JuanDMeGon/Laravel-from-Scratch

  • 17
  • Created Apr 2020
  • Updated Mar 2021

Files in this example

  • app/User.php
View full example

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.