PHPackages                             ymsoft/filament-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. ymsoft/filament-money

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

ymsoft/filament-money
=====================

Filament plugin for convenient storage and management of monetary fields

0.1.4(1mo ago)103.4k↓16%5[2 issues](https://github.com/yarmat/filament-money/issues)[1 PRs](https://github.com/yarmat/filament-money/pulls)MITPHPPHP ^8.2CI passing

Since Dec 1Pushed 1mo agoCompare

[ Source](https://github.com/yarmat/filament-money)[ Packagist](https://packagist.org/packages/ymsoft/filament-money)[ Docs](https://github.com/ymsoft/filament-money)[ GitHub Sponsors](https://github.com/Ymsoft)[ RSS](/packages/ymsoft-filament-money/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (30)Versions (6)Used By (0)

Filament Money
==============

[](#filament-money)

[![Latest Version on Packagist](https://camo.githubusercontent.com/099a008eeb9325a1eea2095c8b9a8242473ebce1e0fc5c8ee8d4264e2c89eb7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796d736f66742f66696c616d656e742d6d6f6e65792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ymsoft/filament-money)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4e66d03d68cd7faa314073646e85efc5d08f72e2517c155a5192d6cadbe57fdb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7961726d61742f66696c616d656e742d6d6f6e65792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/yarmat/filament-money/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/52a1e8ccd07d27c33eba6ce3dbe6e938fb05ecac7efc3a39cc114aaa91c7b562/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7961726d61742f66696c616d656e742d6d6f6e65792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/yarmat/filament-money/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6dd3294c7830aec543e6efecdc4f923b38f04280c8ab2de817168fd1ed4db876/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796d736f66742f66696c616d656e742d6d6f6e65792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ymsoft/filament-money)

[![Filament Money Plugin Banner](arts/preview.jpg)](arts/preview.jpg)

A Filament plugin for convenient storage and management of monetary fields with built-in currency support. This package provides form components and table columns that handle money values with proper formatting, validation, and multi-currency support.

> **Bill Karwin:***"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634"*

Table of Contents
-----------------

[](#table-of-contents)

- [Screenshots](#screenshots)
- [Installation](#installation)
    - [Custom Theme Setup](#custom-theme-setup)
- [Usage](#usage)
    - [Basic Setup](#basic-setup)
    - [Form Components](#form-components)
        - [MoneyField with Changeable Currency](#moneyfield-with-changeable-currency)
        - [MoneyField with Fixed Currency](#moneyfield-with-fixed-currency)
    - [Table Columns](#table-columns)
    - [Infolist Components](#infolist-components)
    - [Plugin Configuration](#plugin-configuration)
        - [Global Currency Settings](#global-currency-settings)
        - [Currency Position](#currency-position)
        - [Global Input Modifier](#global-input-modifier)
        - [Global Select Modifier](#global-select-modifier)
    - [Data Storage](#data-storage)
        - [Using Money Casts](#using-money-casts)
    - [Advanced Usage](#advanced-usage)
        - [Custom Currency Lists](#custom-currency-lists)
        - [Validation](#validation)
        - [Accessing Amount and Currency Separately](#accessing-amount-and-currency-separately)
    - [Complete Example](#complete-example)
    - [API Reference](#api-reference)
        - [MoneyField](#moneyfield)
        - [MoneyColumn](#moneycolumn)
        - [FilamentMoneyPlugin](#filamentmoneyplugin)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
- [License](#license)

Screenshots
-----------

[](#screenshots)

### MoneyField with Changeable Currency (Light Theme)

[](#moneyfield-with-changeable-currency-light-theme)

[![MoneyField Changeable Currency Light](arts/1.png)](arts/1.png)

### MoneyField with Changeable Currency (Dark Theme)

[](#moneyfield-with-changeable-currency-dark-theme)

[![MoneyField Changeable Currency Dark](arts/2.png)](arts/2.png)

### Currency Dropdown with Search

[](#currency-dropdown-with-search)

[![Currency Dropdown](arts/3.png)](arts/3.png)

### Customizable Select Width

[](#customizable-select-width)

[![Customizable Select Width](arts/4.png)](arts/4.png)

### MoneyField with Fixed Currency

[](#moneyfield-with-fixed-currency)

[![MoneyField Fixed Currency](arts/5.png)](arts/5.png)

### MoneyColumn in Tables

[](#moneycolumn-in-tables)

[![MoneyColumn in Tables](arts/6.png)](arts/6.png)

This package is built on top of [cknow/laravel-money](https://github.com/cknow/laravel-money), which provides a robust foundation for handling monetary values in PHP. The `cknow/laravel-money` package wraps the powerful [moneyphp/money](https://github.com/moneyphp/money) library, giving us precise decimal arithmetic, currency conversion, formatting, and proper money object handling. By leveraging this proven library, we ensure that your financial calculations are accurate and your currency data is stored correctly - avoiding the common pitfalls of floating-point arithmetic.

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

[](#installation)

You can install the package via composer:

```
composer require ymsoft/filament-money
```

After installing, run the installation command:

```
php artisan filament-money:install
```

This command will publish the config file and set up the necessary assets.

Alternatively, you can manually publish the config file with:

```
php artisan vendor:publish --tag="filament-money-config"
```

This is the contents of the published config file:

```
return [
    'locale' => config('app.locale', 'en_US'),
    'defaultCurrency' => config('app.currency', 'USD'),
    'defaultFormatter' => null,
    'defaultSerializer' => null,
    'isoCurrenciesPath' => is_dir(__DIR__.'/../vendor')
        ? __DIR__.'/../vendor/moneyphp/money/resources/currency.php'
        : __DIR__.'/../../../moneyphp/money/resources/currency.php',
    'currencies' => [
        'iso' => 'all',
        'bitcoin' => 'all',
        'custom' => [
            // 'MY1' => 2,
            // 'MY2' => 3
        ],
    ],
];
```

### Custom Theme Setup

[](#custom-theme-setup)

To ensure proper styling, you need to use a custom theme and include the plugin's CSS:

**Step 1:** Make sure you have a custom theme configured in your Filament panel.

**Step 2:** Add the plugin's CSS import to your theme file (e.g., `resources/css/filament/admin/theme.css`):

```
@import '../../../../vendor/ymsoft/filament-money/resources/css/styles.css';
```

**Step 3:** Recompile your theme:

```
npm run build
```

> **Note:** Make sure the vendor folder for this plugin is published so that it includes the Tailwind CSS classes.

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

First, register the plugin in your Panel Service Provider:

```
use Ymsoft\FilamentMoney\FilamentMoneyPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentMoneyPlugin::make()
                ->defaultCurrency('USD')
                ->availableCurrencies(['USD', 'EUR', 'GBP'])
                ->currencyPosition('left'), // or 'right'
        ]);
}
```

> **Note:** The plugin configuration provides default settings for all money fields in your panel. However, these settings can be overridden on a per-field basis when needed.

### Form Components

[](#form-components)

The package provides two types of money input fields:

#### MoneyField with Changeable Currency

[](#moneyfield-with-changeable-currency)

Use `MoneyField::make()` to create a money input with a currency selector:

```
use Ymsoft\FilamentMoney\Filament\Forms\Components\MoneyField;
use Cknow\Money\Money;

MoneyField::make('price')
```

This will create a fused group with:

- A text input for the amount
- A select dropdown for currency selection

**Setting Available Currencies:**

By default, currencies are inherited from the plugin configuration. You can override them per field:

```
MoneyField::make('price')
    ->currencies(['USD', 'EUR', 'GBP', 'JPY'])
```

**Currency Position:**

By default, the currency position is inherited from the plugin configuration. You can override it per field:

```
MoneyField::make('price')
    ->currencyPosition('right') // 'left' or 'right'
```

**Select Width:**

```
MoneyField::make('price')
    ->selectWidth('100px')
```

**Default Value:**

```
use Cknow\Money\Money;

MoneyField::make('price')
    ->default(new Money(100, 'USD'))
```

**Modifying Input Field:**

```
MoneyField::make('price')
    ->input(fn ($input) => $input
        ->placeholder('0.00')
        ->step('0.01')
        ->minValue(0)
    )
```

**Modifying Currency Select:**

```
MoneyField::make('price')
    ->select(fn ($select) => $select
        ->searchable()
    )
```

#### MoneyField with Fixed Currency

[](#moneyfield-with-fixed-currency-1)

Use `MoneyField::fixed()` to create a money input with a fixed currency (shown as prefix/suffix):

```
use Ymsoft\FilamentMoney\Filament\Forms\Components\MoneyField;
use Cknow\Money\Money;

MoneyField::fixed('salary')
```

This will create a single text input with the currency displayed as a prefix or suffix.

**Currency Position:**

By default, the currency position is inherited from the plugin configuration. You can override it per field:

```
MoneyField::fixed('salary')
    ->currencyPosition('left') // shows currency as prefix
    // or
    ->currencyPosition('right') // shows currency as suffix
```

**Default Value:**

```
MoneyField::fixed('salary')
    ->default(new Money(50000, 'USD'))
```

**Modifying Input Field:**

```
MoneyField::fixed('salary')
    ->input(fn ($input) => $input
        ->placeholder('Enter amount')
        ->suffix('per month')
    )
```

**Label Customization:**

```
MoneyField::fixed('salary')
    ->label('Monthly Salary')
    ->translateLabel()
    ->hiddenLabel() // if you want to hide the label
```

### Table Columns

[](#table-columns)

Display money values in tables with automatic formatting:

```
use Ymsoft\FilamentMoney\Filament\Tables\Columns\MoneyColumn;

MoneyColumn::make('price')
```

The column automatically:

- Formats the money value according to the currency
- Displays the currency symbol or code
- Handles different decimal precision based on currency (e.g., 2 decimals for USD, 0 for JPY)
- For currencies with more than 2 decimal places, displays the decimal format with currency code

**Example Output:**

- `$1,234.56` for USD
- `€1.234,56` for EUR
- `¥1,235` for JPY (no decimals)
- `0.00123456 BTC` for Bitcoin (high precision)

### Infolist Components

[](#infolist-components)

Display money values in infolists with automatic formatting:

```
use Ymsoft\FilamentMoney\Filament\Infolists\Components\MoneyEntry;

MoneyEntry::make('price')
```

The entry automatically:

- Formats the money value according to the currency
- Displays the currency symbol or code
- Handles different decimal precision based on currency (e.g., 2 decimals for USD, 0 for JPY)
- For currencies with more than 2 decimal places, displays the decimal format with currency code

**Example Output:**

- `$1,234.56` for USD
- `€1.234,56` for EUR
- `¥1,235` for JPY (no decimals)
- `0.00123456 BTC` for Bitcoin (high precision)

### Plugin Configuration

[](#plugin-configuration)

#### Global Currency Settings

[](#global-currency-settings)

Configure default currencies for all money fields in your panel:

```
FilamentMoneyPlugin::make()
    ->defaultCurrency('EUR')
    ->availableCurrencies(['EUR', 'USD', 'GBP', 'CHF'])
```

#### Currency Position

[](#currency-position)

Set the default position for currency display:

```
FilamentMoneyPlugin::make()
    ->currencyPosition('right') // or 'left'
```

#### Global Input Modifier

[](#global-input-modifier)

Apply modifications to all money input fields:

```
FilamentMoneyPlugin::make()
    ->input(fn ($input) => $input
        ->step('0.01')
        ->minValue(0)
        ->maxValue(999999.99)
    )
```

#### Global Select Modifier

[](#global-select-modifier)

Apply modifications to all currency select fields:

```
FilamentMoneyPlugin::make()
    ->select(fn ($select) => $select
        ->searchable()
    )
```

### Data Storage

[](#data-storage)

The money field stores data as a `Money` object from the `cknow/laravel-money` package. When saving to the database, it will be serialized. When loading from the database, it will be automatically converted back to a `Money` object.

#### Using Money Casts

[](#using-money-casts)

The `cknow/laravel-money` package provides several cast options for storing money values in your database. These casts handle the conversion between database values and Money objects automatically.

**Available Casts:**

```
use Cknow\Money\Casts\MoneyDecimalCast;
use Cknow\Money\Casts\MoneyIntegerCast;
use Cknow\Money\Casts\MoneyStringCast;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $casts = [
        // Cast money as decimal using the currency defined in the package config
        'price' => MoneyDecimalCast::class,

        // Cast money as integer using the defined currency (e.g., cents for USD)
        'cost' => MoneyIntegerCast::class . ':USD',

        // Cast money as string using the currency defined in the model attribute 'currency'
        'salary' => MoneyIntegerCast::class . ':currency',

        // Cast money as decimal using the defined currency and forcing decimals
        'budget' => MoneyDecimalCast::class . ':EUR,true',
    ];
}
```

**Cast Options Explained:**

1. **MoneyDecimalCast** - Stores money as decimal (e.g., `19.99`)

    - `MoneyDecimalCast::class` - Uses default currency from config
    - `MoneyDecimalCast::class . ':USD'` - Uses specified currency
    - `MoneyDecimalCast::class . ':USD,true'` - Forces decimal places
2. **MoneyIntegerCast** - Stores money as integer in smallest unit (e.g., `1999` cents)

    - `MoneyIntegerCast::class . ':USD'` - Stores as cents for USD
    - Best for exact calculations without floating-point errors
3. **MoneyStringCast** - Stores money as string with dynamic currency

    - `MoneyStringCast::class . ':currency'` - Reads currency from model's `currency` attribute
    - Useful when currency varies per record

**Migration Examples:**

```
// For MoneyDecimalCast or MoneyStringCast
Schema::create('products', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->decimal('price', 15, 2); // 15 digits total, 2 decimal places
    $table->string('currency', 3)->default('USD'); // If using MoneyStringCast
    $table->timestamps();
});

// For MoneyIntegerCast
Schema::create('products', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->bigInteger('price'); // Stores in smallest unit (cents, pence, etc.)
    $table->timestamps();
});
```

**Example Model with Multiple Money Fields:**

```
use Cknow\Money\Casts\MoneyDecimalCast;
use Cknow\Money\Casts\MoneyIntegerCast;
use Cknow\Money\Money;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = ['name', 'price', 'cost', 'tax'];

    protected $casts = [
        'price' => MoneyIntegerCast::class . ':USD',  // stored as cents
        'cost' => MoneyDecimalCast::class . ':USD',    // stored as decimal
        'tax' => MoneyDecimalCast::class . ':USD,true', // forced decimals
    ];
}

// Usage in your code:
$product = new Product();
$product->price = new Money(1999, 'USD'); // $19.99
$product->save();

// Retrieving:
$product->price; // Returns Money object
$product->price->format(); // Returns "$19.99"
```

For more information about money casts and the underlying library, see the [cknow/laravel-money documentation](https://github.com/cknow/laravel-money).

### Advanced Usage

[](#advanced-usage)

#### Custom Currency Lists

[](#custom-currency-lists)

You can define custom currencies per field:

```
MoneyField::make('price')
    ->currencies(['USD', 'EUR', 'CUSTOM'])
```

#### Validation

[](#validation)

The package automatically adds the `money` validation rule to the input field:

```
// The money validation ensures proper decimal format
MoneyField::make('price')
    ->input(fn ($input) => $input
        ->required()
        ->minValue(0)
        ->maxValue(1000000)
    )
```

### Complete Example

[](#complete-example)

Here's a complete example of a product resource with money fields:

```
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use Filament\Tables;
use Ymsoft\FilamentMoney\Filament\Forms\Components\MoneyField;
use Ymsoft\FilamentMoney\Filament\Tables\Columns\MoneyColumn;
use Cknow\Money\Money;

class ProductResource extends Resource
{
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('name')
                    ->required(),

                MoneyField::make('price')
                    ->currencies(['USD', 'EUR', 'GBP'])
                    ->default(new Money(0, 'USD'))
                    ->required()
                    ->input(fn ($input) => $input
                        ->minValue(0)
                        ->step('0.01')
                    ),

                MoneyField::fixed('cost')
                    ->currencyPosition('left')
                    ->default(new Money(currency: 'USD'))
                    ->input(fn ($input) => $input
                        ->minValue(0)
                    ),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('name'),
                MoneyColumn::make('price'),
                MoneyColumn::make('cost'),
            ]);
    }
}
```

### API Reference

[](#api-reference)

#### MoneyField

[](#moneyfield)

##### Static Methods

[](#static-methods)

- `MoneyField::make(string $name)` - Creates a money field with changeable currency
    - `MoneyField::fixed(string $name)` - Creates a money field with fixed currency

##### Methods (MoneyChangeableCurrency)

[](#methods-moneychangeablecurrency)

- `currencies(array|Closure $currencies)` - Set available currencies for the select dropdown
- `currencyPosition(string|Closure $position)` - Set currency position ('left' or 'right')
- `selectWidth(string|Closure $width)` - Set the width of the currency select (default: '80px')
- `input(Closure $callback)` - Modify the amount input field
- `select(Closure $callback)` - Modify the currency select field
- `default(Money $money)` - Set default money value

##### Methods (MoneyFixedCurrency)

[](#methods-moneyfixedcurrency)

- `currencyPosition(string|Closure $position)` - Set currency position ('left' or 'right')
- `input(Closure $callback)` - Modify the amount input field
- `default(Money $money)` - Set default money value
- `label(string|Htmlable|Closure|null $label)` - Set field label
- `translateLabel(bool $shouldTranslate = true)` - Enable label translation
- `hiddenLabel(bool|Closure $condition = true)` - Hide the field label

#### MoneyColumn

[](#moneycolumn)

Extends `Filament\Tables\Columns\TextColumn` with automatic money formatting.

All standard TextColumn methods are available.

#### FilamentMoneyPlugin

[](#filamentmoneyplugin)

##### Methods

[](#methods)

- `make()` - Create plugin instance
- `defaultCurrency(string $currency)` - Set default currency
- `availableCurrencies(array $currencies)` - Set available currencies
- `currencyPosition(string $position)` - Set default currency position ('left' or 'right')
- `input(Closure $callback)` - Global input field modifier
- `select(Closure $callback)` - Global select field modifier

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [YarmaT](https://github.com/YarmaT)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance85

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% 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 ~28 days

Total

5

Last Release

54d ago

### Community

Maintainers

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

---

Top Contributors

[![tvjpn](https://avatars.githubusercontent.com/u/15500987?v=4)](https://github.com/tvjpn "tvjpn (15 commits)")[![yarmat](https://avatars.githubusercontent.com/u/16940233?v=4)](https://github.com/yarmat "yarmat (9 commits)")[![Androlax2](https://avatars.githubusercontent.com/u/39646949?v=4)](https://github.com/Androlax2 "Androlax2 (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![jeffreyvanhees](https://avatars.githubusercontent.com/u/8754630?v=4)](https://github.com/jeffreyvanhees "jeffreyvanhees (1 commits)")

---

Tags

laravelfilament-moneyymsoft

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ymsoft-filament-money/health.svg)

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

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[pboivin/filament-peek

Full-screen page preview modal for Filament

253319.6k12](/packages/pboivin-filament-peek)[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

124139.3k2](/packages/dotswan-filament-map-picker)[creagia/filament-code-field

A Filamentphp input field to edit or view code data.

58289.3k3](/packages/creagia-filament-code-field)[swisnl/filament-backgrounds

Beautiful backgrounds for Filament auth pages

54149.2k6](/packages/swisnl-filament-backgrounds)[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)
