PHPackages                             kazuto/laravel-money - 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. kazuto/laravel-money

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

kazuto/laravel-money
====================

Money Cast and Facade for Laravel

1.2.1(4y ago)04MITPHPPHP ^8.0

Since Oct 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Kazuto/laravel-money)[ Packagist](https://packagist.org/packages/kazuto/laravel-money)[ Docs](https://github.com/kazuto/laravel-money)[ GitHub Sponsors](https://github.com/Kazuto)[ RSS](/packages/kazuto-laravel-money/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (9)Versions (5)Used By (0)

Money Cast and Facade for Laravel
=================================

[](#money-cast-and-facade-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/128545e9042eb5d9cd384dc8db175158ed83e8eec7440153b617698426607de9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b617a75746f2f6c61726176656c2d6d6f6e65792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kazuto/laravel-money)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8f54c746761100fb7e29e8e2bef081136337c1927af1ace9e7ca37abfe0cb9ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b617a75746f2f6c61726176656c2d6d6f6e65792f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/kazuto/laravel-money/actions?query=workflow%3Arun-tests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/fffe76f24adaf358ff3e1af3b07e2e317145f3adb9ce7c64ac6e8b7645cad730/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b617a75746f2f6c61726176656c2d6d6f6e65792f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/kazuto/laravel-money/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/e4c0506456c8f7672c4fa34ae6c45f858502b4e6bbb3ab59c3a19c0ed95e754f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b617a75746f2f6c61726176656c2d6d6f6e65792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kazuto/laravel-money)

This package adds a money cast and money facade to simplify storing financial values in the database by adding them as an integer column instead of float, double, or decimal, thus eliminating the possibility of floating point errors and resulting miscalculations.

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

[](#installation)

You can install the package via composer:

```
composer require kazuto/laravel-money
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Kazuto\LaravelMoney\MoneyServiceProvider"
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Kazuto\LaravelMoney\MoneyServiceProvider" --tag="money-config"
```

This is the contents of the published config file:

```
return [
  'locale_iso' => 'en_US'
];
```

Usage
-----

[](#usage)

```
// Base
Money::fromInt(524)->toInt();   // 524
Money::fromInt(524)->toFloat(); // 5.24
Money::fromInt(524)->toText();  // $5.24
Money::fromInt(524)->toArray();
// [
//   'value' => 524,
//   'formatted' => '$5.24',
//   'currency' => 'USD',
//   'symbol' => '$',
// ]

Money::fromFloat(5.24)->toInt();    // 524
Money::fromFloat(5.24)->toFloat();  // 5.24
Money::fromFloat(5.24)->toText();   // $5.24
Money::fromFloat(5.24)->toArray();
// [
//   'value' => 524,
//   'formatted' => '$5.24',
//   'currency' => 'USD',
//   'symbol' => '$',
// ]

// Math

// add(Money|int|float)
Money::fromInt(524)->add(123);                    // 647
Money::fromInt(524)->add(1.23);                   // 647
Money::fromInt(524)->add(Money::fromFloat(1.23)); // 647

// substract(Money|int|float)
Money::fromInt(524)->substract(123);                    // 401
Money::fromInt(524)->substract(1.23);                   // 401
Money::fromInt(524)->substract(Money::fromFloat(1.23)); // 401

// multiply(int|float)
Money::fromInt(524)->multiply(2);     // 1048
Money::fromInt(524)->multiply(1.23);  // 645 (rounded from 644.52)

// divide(int|float)
Money::fromInt(524)->divide(2);       // 262
Money::fromInt(524)->divide(1.23);    // 426 (rounded from 426.01)

// Comparisons

// isEqualTo(Money|int|float)
Money::fromInt(524)->isEqualTo(524);                    // true
Money::fromInt(524)->isEqualTo(Money::fromFloat(5.24)); // true
Money::fromInt(524)->isEqualTo(1.23);                   // false
Money::fromInt(524)->isEqualTo(Money::fromInt(123));    // false

// isGreaterThan(Money|int|float)
Money::fromInt(524)->isGreaterThan(123);                    // true
Money::fromInt(524)->isGreaterThan(Money::fromFloat(1.23)); // true
Money::fromInt(524)->isGreaterThan(8.58);                   // false
Money::fromInt(524)->isGreaterThan(Money::fromInt(858));    // false
Money::fromInt(524)->isGreaterThan(524);                    // false
Money::fromInt(524)->isGreaterThan(Money::fromFloat(5.24)); // false

// isGreaterThanOrEqual(Money|int|float)
Money::fromInt(524)->isGreaterThanOrEqual(8.58);                   // false
Money::fromInt(524)->isGreaterThanOrEqual(524);                    // true
Money::fromInt(524)->isGreaterThanOrEqual(Money::fromFloat(5.24)); // true

// isLessThan(Money|int|float)
Money::fromInt(524)->isLessThan(8.58);                   // true
Money::fromInt(524)->isLessThan(Money::fromInt(858));    // true
Money::fromInt(524)->isLessThan(123);                    // false
Money::fromInt(524)->isLessThan(Money::fromFloat(1.23)); // false
Money::fromInt(524)->isLessThan(524);                    // false
Money::fromInt(524)->isLessThan(Money::fromFloat(5.24)); // false

// isLessThanOrEqual(Money|int|float)
Money::fromInt(524)->isLessThanOrEqual(2.24);                   // false
Money::fromInt(524)->isLessThanOrEqual(524);                    // true
Money::fromInt(524)->isLessThanOrEqual(Money::fromFloat(5.24)); // true
```

Testing
-------

[](#testing)

```
# Unit Tests
composer test:run

# Coverage
composer test:coverage
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Kai Mayer](https://github.com/Kazuto)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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 ~37 days

Total

4

Last Release

1551d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/183d6e2a837ca38ebdad3ff1e423c7c53022bc0717fdecb3c6413010cbe6fc84?d=identicon)[Kazuto](/maintainers/Kazuto)

---

Top Contributors

[![Kazuto](https://avatars.githubusercontent.com/u/25435034?v=4)](https://github.com/Kazuto "Kazuto (5 commits)")

---

Tags

laravelmoneyKazuto

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/kazuto-laravel-money/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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