PHPackages                             jgrossi/laravel-mutable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jgrossi/laravel-mutable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jgrossi/laravel-mutable
=======================

Change model attributes values easily

0.1.1(8y ago)123MITPHP

Since Jul 20Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jgrossi/laravel-mutable)[ Packagist](https://packagist.org/packages/jgrossi/laravel-mutable)[ Docs](http://github.com/jgrossi/laravel-mutable)[ RSS](/packages/jgrossi-laravel-mutable/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (4)Used By (0)

Laravel Mutable
===============

[](#laravel-mutable)

> Change Laravel models `toArray()` values using a simple and clean way

Installation
============

[](#installation)

```
composer require jgrossi/laravel-mutable

```

Usage
-----

[](#usage)

First add `Mutable` trait to the model you want to change values:

```
use Jgrossi\Mutable\Mutable;

class User extends Eloquent
{
    use Mutable;
}
```

Then create a `UserMutator` class in any place in your app (or give it other name if you prefer). Then set the `$mutator` property in your model:

```
use App\Models\Mutators\UserMutator;
use Jgrossi\Mutable\Mutable;

class User extends Eloquent
{
    use Mutable;

    protected $mutator = UserMutator::class;
}
```

In your mutator class you might have one method for each attribute you want to change:

```
namespace App\Models\Mutators;

use Carbon\Carbon;
use Jgrossi\Mutable\Mutator;

class UserMutator extends Mutator
{
    public function firstName($value)
    {
        return ucfirst($value);
    }

    public function createdAt(Carbon $date)
    {
        return $date->format('Y-m-d');
    }
}
```

Then when using `$user->toArray()` you'll have the `first_name` attributes changed.

```
class FooController extends Controller
{
    public function show($id)
    {
        $user = User::findOrFail($id);

        return $user; // returns the changed User as array
    }
}
```

 Licence
=========================================

[](#-licence)

[MIT License](http://jgrossi.mit-license.org/) © Junior Grossi

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3215d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/349896810d1d87575ac58c892869fb38b848d7d5b210bbc9baa400c421d8e824?d=identicon)[jgrossi](/maintainers/jgrossi)

---

Top Contributors

[![jgrossi](https://avatars.githubusercontent.com/u/1175275?v=4)](https://github.com/jgrossi "jgrossi (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jgrossi-laravel-mutable/health.svg)

```
[![Health](https://phpackages.com/badges/jgrossi-laravel-mutable/health.svg)](https://phpackages.com/packages/jgrossi-laravel-mutable)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[efureev/laravel-trees

Multi-Tree structures for Laravel

14253.3k4](/packages/efureev-laravel-trees)[illuminatech/balance

Provides support for Balance accounting system based on debit and credit principle

16137.4k](/packages/illuminatech-balance)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[glhd/special

1929.4k](/packages/glhd-special)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
