PHPackages                             giordanolima/decimal-mutators - 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. [Database &amp; ORM](/categories/database)
4. /
5. giordanolima/decimal-mutators

ActiveLibrary[Database &amp; ORM](/categories/database)

giordanolima/decimal-mutators
=============================

Add a short way to create accessors and mutators for decimal fields

1.1.4(5y ago)151.0k3MITPHPPHP &gt;=5.4.0

Since Dec 8Pushed 5y ago2 watchersCompare

[ Source](https://github.com/giordanolima/decimal-mutators)[ Packagist](https://packagist.org/packages/giordanolima/decimal-mutators)[ RSS](/packages/giordanolima-decimal-mutators/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/099de88d35731b303f85e19629377cfdd0b8c7683662dae673111d92df4abd28/68747470733a2f2f706f7365722e707567782e6f72672f67696f7264616e6f6c696d612f646563696d616c2d6d757461746f72732f762f737461626c65)](https://packagist.org/packages/giordanolima/decimal-mutators) [![Total Downloads](https://camo.githubusercontent.com/63ec52662573a422554f9b4287b18cf4a3cdc987a6e235e8d91b80db7e09fbfa/68747470733a2f2f706f7365722e707567782e6f72672f67696f7264616e6f6c696d612f646563696d616c2d6d757461746f72732f646f776e6c6f616473)](https://packagist.org/packages/giordanolima/decimal-mutators) [![License](https://camo.githubusercontent.com/686eaa4cc82fcc08db4d7df3d17d218742692eb5fb23a8e63d0c3ecbc6fd5216/68747470733a2f2f706f7365722e707567782e6f72672f67696f7264616e6f6c696d612f646563696d616c2d6d757461746f72732f6c6963656e7365)](https://packagist.org/packages/giordanolima/decimal-mutators) [![StyleCI](https://camo.githubusercontent.com/c6434c9eea782dd70440c9e91c292a4a6f601d1762d60fd51d6c1d730743e5ee/68747470733a2f2f7374796c6563692e696f2f7265706f732f34373632343439332f736869656c64)](https://styleci.io/repos/47624493)

Decimal Mutators for Laravel
----------------------------

[](#decimal-mutators-for-laravel)

**Decimal Mutators** provides a short way to create accessors and mutators for decimal fields.

Install
-------

[](#install)

Install package through Composer

```
composer require giordanolima/decimal-mutators
```

### Usage

[](#usage)

You should use it as a trait of your model, and declare which fields you want to apply the mutators:

```
use Illuminate\Database\Eloquent\Model,
    GiordanoLima\DecimalMutators\DecimalMutators;
class MyModel extends Model
{
	use DecimalMutators;

	protected $decimalsFields = [
            'decimal_field_1',
            'decimal_field_2',
            'decimal_field_3',
            'decimal_field_4'
        ];

}
```

By default, the trait will get the data from database and will replace "," (comma) as thousand separator to ""(blank) and will replace "." (dot) as decimal separator to "," (comma). The behavior will be like this:

```
$myModel = MyModel::find(1);
$myModel->decimal_field_1 = '200,00';
$myModel->save(); // It will store as 200.00

$myModel = MyModel::find(1);
echo $myModel->decimal_field_1; // Will print 200,00
```

By default, it gonna be used 2 for decimal points... If you need change it, you can set the option:

```
protected $decimalsOptions = [
    "decimals" => 4, // now, the fields will be stored and printed with 4 decimals point
];
```

If you want to replace defaults separators, you can replace with:

```
protected $decimalsOptions = [
    "setDecimalsFrom" => ",",
    "setDecimalsTo" => ".",
    "setThounsandFrom" => ".",
    "setThounsandTo" => "",
    "getDecimalsFrom" => ".",
    "getDecimalsTo" => ",",
    "getThounsandFrom" => ",",
    "getThounsandTo" => "",
];
```

You can disable the mutators:

```
MyModel::$disableGetMutator = true;
echo $myModel->decimal_field_1; // Will print 200.00
MyModel::$disableGetMutator = false;
echo $myModel->decimal_field_1; // Will print 200,00
```

```
MyModel::$disableSetMutator = true;
$myModel->decimal_field_1 = '200,00';
$myModel->save(); // It will store as 200,00
MyModel::$disableSetMutator = false;
$myModel->decimal_field_1 = '200,00';
$myModel->save(); // It will store as 200.00
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 92% 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 ~254 days

Recently: every ~435 days

Total

8

Last Release

2034d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/961a7e8f71b1e25611c4156995cdf0c064024dd629479c31b92f938035ee797b?d=identicon)[giordanolima](/maintainers/giordanolima)

---

Top Contributors

[![giordanolima](https://avatars.githubusercontent.com/u/8314190?v=4)](https://github.com/giordanolima "giordanolima (23 commits)")[![georgecpacheco](https://avatars.githubusercontent.com/u/2250742?v=4)](https://github.com/georgecpacheco "georgecpacheco (2 commits)")

---

Tags

laraveleloquentdecimallaravel5accessormutatoraccessorsmutatorsdecimals

### Embed Badge

![Health badge](/badges/giordanolima-decimal-mutators/health.svg)

```
[![Health](https://phpackages.com/badges/giordanolima-decimal-mutators/health.svg)](https://phpackages.com/packages/giordanolima-decimal-mutators)
```

###  Alternatives

[rutorika/sortable

Adds sortable behavior and ordering to Laravel Eloquent models. Grouping and many to many supported.

299992.5k14](/packages/rutorika-sortable)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[delatbabel/elocryptfive

Automatically encrypt and decrypt Eloquent attributes with ease.

8493.0k](/packages/delatbabel-elocryptfive)[cviebrock/eloquent-typecast

Trait for Eloquent models to force type-casting on retrieved values

2468.0k](/packages/cviebrock-eloquent-typecast)[korridor/laravel-computed-attributes

Laravel package that adds computed attributes to eloquent models. A computed attribute is an accessor were the computed value is saved in the database.

1237.6k](/packages/korridor-laravel-computed-attributes)[dolphiq/laravel-aescrypt

AES encrypt and decrypt Eloquent attributes inspired by elocryptfive

171.7k](/packages/dolphiq-laravel-aescrypt)

PHPackages © 2026

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