PHPackages                             roboticsexpert/laravel-decimal - 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. roboticsexpert/laravel-decimal

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

roboticsexpert/laravel-decimal
==============================

Easy way to add decimal functionality to your laravel models

1.0.0(4y ago)564012MITPHP

Since Feb 26Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/roboticsexpert/laravel-decimal)[ Packagist](https://packagist.org/packages/roboticsexpert/laravel-decimal)[ RSS](/packages/roboticsexpert-laravel-decimal/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (2)

Laravel Decimal
===============

[](#laravel-decimal)

this package uses php-decimal for handle decimal. you can see documentation with this link:

you can use php-decimal in your php project, but if you need to have decimal in your model you should have decimal cast in your laravel project. with this project you will have that:)

this package helps you to have Decimal object in your models and do not loose anything in casting and saving in database.

Installation
------------

[](#installation)

```
composer require roboticsexpert/laravel-decimal
```

Usage
-----

[](#usage)

first you need to change your migration like this

```
$table->unsignedDecimal('your_field', 32, 16);
```

after installing, go to that model you need have decimal attribute and add that field in cast array like this:

```
use Roboticsexpert\LaravelDecimal\DecimalCast;

class YourModel extend Model {
    public $cast=[
        'your_field' => DecimalCast::class,
    ];

}
```

after adding that you can set value to your model like this:

```
$value = new \Decimal\Decimal('12345.131123123123123');
$model=new YourModel();
$model->your_filed=$value;
... (other stuff)
$model->save();
```

for getting value it will return Decimal object and you can do anything you want with that:

```
$model=YourModel::first();
$model->your_filed // \Decimal\Decimal "12345.131123123123123"

//add 123 to your field
$model->your_field=$model->your_field->add('123');

//sub 123 from your field
$model->your_field=$model->your_field->sub('123');

// check php-decimal package for other methods you can use!
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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

Unknown

Total

1

Last Release

1537d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fa72ec88ecd099cdcc983cf4e8f3137c61b2832630a7c6ba4684ad17faf56b2f?d=identicon)[roboticsexpert](/maintainers/roboticsexpert)

---

Top Contributors

[![roboticsexpert](https://avatars.githubusercontent.com/u/9366277?v=4)](https://github.com/roboticsexpert "roboticsexpert (5 commits)")[![azibom](https://avatars.githubusercontent.com/u/34370960?v=4)](https://github.com/azibom "azibom (2 commits)")

---

Tags

decimaleloquentlaravelmodelphpphp-decimal

### Embed Badge

![Health badge](/badges/roboticsexpert-laravel-decimal/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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