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

ActiveLibrary

freshleafmedia/laravel-money-cast
=================================

A Laravel attribute cast for Money values

1.0.1(2y ago)28MITPHP

Since Nov 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/freshleafmedia/laravel-money-cast)[ Packagist](https://packagist.org/packages/freshleafmedia/laravel-money-cast)[ RSS](/packages/freshleafmedia-laravel-money-cast/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Laravel Money Cast
==================

[](#laravel-money-cast)

A Money cast for Laravel models

Overview
--------

[](#overview)

This library provides a Laravel Attribute Cast which serialises [Money](https://github.com/moneyphp/money) instances into strings suitable for database storage.

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

[](#installation)

```
composer require freshleafmedia/laravel-money-cast

```

Usage
-----

[](#usage)

```
use Freshleafmedia\MoneyCast\MoneyCast;
use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
    // ...

    protected $casts = [
        'cost' => MoneyCast::class,
    ];

    // ...
}
```

### Saving

[](#saving)

```
$model = new MyModel();
$model->cost = new \Money\Money('100', new \Money\Currency('GBP'));
$model->save(); // 'GBP100' is persisted to the database.
```

### Retrieving

[](#retrieving)

```
$cost = MyModel::first()->cost; // Money\Money

$cost->getAmount() // '100'
$cost->getCurrency()->getCode() // 'GBP'
```

Decimal Amounts
---------------

[](#decimal-amounts)

Note that due to the way [moneyphp/money](https://github.com/moneyphp/money) works amounts are in the smallest unit. For example `GBP100` =&gt; £1.00, `USD100` =&gt; $1.00, `JPY100` =&gt; ¥100, etc.

See the [Formatting section](https://www.moneyphp.org/en/stable/features/formatting.html) of the moneyphp docs for details

Tests
-----

[](#tests)

Unit tests can be run via `composer test`

License
-------

[](#license)

See [LICENSE](LICENSE)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Total

2

Last Release

959d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10062339?v=4)[Freshleaf Media](/maintainers/freshleafmedia)[@freshleafmedia](https://github.com/freshleafmedia)

---

Top Contributors

[![freshleafmedia](https://avatars.githubusercontent.com/u/10062339?v=4)](https://github.com/freshleafmedia "freshleafmedia (6 commits)")

---

Tags

attributecastlaravelmoneymoneyphp

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[timokoerber/laravel-one-time-operations

Run operations once after deployment - just like you do it with migrations!

6481.7M11](/packages/timokoerber-laravel-one-time-operations)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

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