PHPackages                             pelmered/larapara - 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. pelmered/larapara

ActiveLibrary

pelmered/larapara
=================

315.6k↑13.2%2[2 PRs](https://github.com/pelmered/larapara/pulls)PHPCI passing

Since May 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pelmered/larapara)[ Packagist](https://packagist.org/packages/pelmered/larapara)[ RSS](/packages/pelmered-larapara/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Filament Money Field
====================

[](#filament-money-field)

Money field powered by [Money PHP](https://www.moneyphp.org/en/stable/).

This package gives much better localization support for money fields in Filament than most other packages, and especially the built-in money support on TextColumns and TextEntries. For example when it comes to currency symbols and decimal and thousands separators. Especially for more obscure currencies. This also includes an input field that handles localized formats.

Example of a money field with Swedish localization. This package would give "1 234,56 kr", while most other solutions probably would give you something like "SEK 1234.56" which is not the correct format for Sweden.

[![Latest Stable Version](https://camo.githubusercontent.com/ed7b0cfd23487c8a4aae2b841deb451d755dddeef6b7d8e7af90121541e9f91c/68747470733a2f2f706f7365722e707567782e6f72672f70656c6d657265642f6c617261706172612f762f737461626c65)](https://packagist.org/packages/pelmered/larapara)[![Total Downloads](https://camo.githubusercontent.com/a68ad246bf42a73061659bc5cf413a5fb7b1968662aefc49477ba245a270e66d/68747470733a2f2f706f7365722e707567782e6f72672f70656c6d657265642f6c617261706172612f642f746f74616c)](//packagist.org/packages/pelmered/larapara)[![Monthly Downloads](https://camo.githubusercontent.com/117dd6644c63560458c8a7969d743aa79c25ec19d46f164c5690a881484d1169/68747470733a2f2f706f7365722e707567782e6f72672f70656c6d657265642f6c617261706172612f642f6d6f6e74686c79)](//packagist.org/packages/pelmered/larapara)[![License](https://camo.githubusercontent.com/64a595fc900b52487611a4ac9fe648b787c6b31e8e809807fc1c0f8779f72dda/68747470733a2f2f706f7365722e707567782e6f72672f70656c6d657265642f6c617261706172612f6c6963656e7365)](https://packagist.org/packages/pelmered/larapara)

[![Tests](https://github.com/pelmered/larapara/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/pelmered/larapara/actions/workflows/tests.yml)[![Test Coverage](https://camo.githubusercontent.com/3b6e748523a44d52822311562414ab60944b3d9eb7c7f7843eafcb8c4a69a67e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6f74746572776973652e6170702f62616467652f6769746875622f70656c6d657265642f6c617261706172612f636f7665726167652f32356566383635652d353233352d343737352d613335372d323436626566333832393363)](https://otterwise.app/github/pelmered/larapara)[![Type Coverage](https://camo.githubusercontent.com/9a21dec17afe44cf5a944f5500345db7262d59b4cb4e200c4eea812baffa8337/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6f74746572776973652e6170702f62616467652f6769746875622f70656c6d657265642f6c617261706172612f747970652f32356566383635652d353233352d343737352d613335372d323436626566333832393363)](https://otterwise.app/github/pelmered/larapara)[![Complexity](https://camo.githubusercontent.com/73f9d9199f10eac6f24b395e67668203faaeac15d085577737a9bdbbf0ed854e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6f74746572776973652e6170702f62616467652f6769746875622f70656c6d657265642f6c617261706172612f636f6d706c65786974792f32356566383635652d353233352d343737352d613335372d323436626566333832393363)](https://otterwise.app/github/pelmered/larapara)[![Crap](https://camo.githubusercontent.com/8377aae955749f99ded89ce674c1923edf325e45584443b2248e034b5d5c3865/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6f74746572776973652e6170702f62616467652f6769746875622f70656c6d657265642f6c617261706172612f637261702f32356566383635652d353233352d343737352d613335372d323436626566333832393363)](https://otterwise.app/github/pelmered/larapara)[![PHPStan](https://camo.githubusercontent.com/f60d96f7c2579690ab6dfa8918f777fe93a02a92301c661eb38a85861a92b780/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c6174)](https://otterwise.app/github/pelmered/larapara)

[![Tested with Laravel 11 to 12](https://camo.githubusercontent.com/5f1df61cbca4315604555466db51a83805d6f10f4aa084ad6cd0c11cad860aad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f546573746564253230776974682532304c61726176656c2d313125323025374325323031322d627269676874677265656e3f6d61784167653d32343139323030)](https://github.com/pelmered/larapara/actions/workflows/tests.yml)[![Tested on PHP 8.2 to 8.4](https://camo.githubusercontent.com/d45b11711af3df72431b86e8357cbe4cb405b997b729ab887864ed870d52de1b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5465737465642532306f6e2532305048502d382e32253230253743253230382e33253230253743253230382e342d627269676874677265656e2e7376673f6d61784167653d32343139323030)](https://github.com/pelmered/larapara/actions/workflows/tests.yml)[![Tested on OS:es Linux, MacOS, Windows](https://camo.githubusercontent.com/9926c282f083c7a73d0e09f2ebd3b679617d43ce70c34e8fc09029fa10025f74/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5465737465642532306f6e2532306c61737465737425323076657273696f6e732532306f662d2532305562756e74752532302537432532304d61634f5325323025374325323057696e646f77732d627269676874677265656e2e7376673f6d61784167653d32343139323030)](https://github.com/pelmered/larapara/actions/workflows/tests.yml)

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.24.1 or higher
- Filament 3.2 or higher
- [PHP Internationalization extension (intl)](https://www.php.net/manual/en/intro.intl.php)
- The database column type should be a either decimal or integer (amount stored with minor units i.e. cents).

Key features
------------

[](#key-features)

- Fully localized money fields in most locales. Report in an issue if you find a locale that is not working as expected.
- Includes fully localized:
    - Input field with currency symbols and (optional) input mask.
    - Column for tables.
    - Entry for infolists.
- Modern and strict tooling. PHP 8.2+, PEST, PHPStan Level 8, Pint, Rector.
- Comprehensive test suite. 100 % type coverage and 99+ % test coverage.
- Configure currency and locale globally or per field.
- Validation rules for valid numeric input, and min/max values.
- A [money formatter class](MONEY-FORMATTER.md) that could be used in your project. Any public method there is considered stable and will not change without major version update. See [documentation](MONEY-FORMATTER.md) for details.

**Are you using this package to make profits? Please consider [sponsoring me](https://github.com/sponsors/pelmered).**

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

[](#installation)

```
composer require pelmered/larapara
```

Upgrade to 2.\* from 1.\*
-------------------------

[](#upgrade-to-2-from-1)

See [upgrade guide](UPGRADE.md).

Configuration
-------------

[](#configuration)

### Configure your locale

[](#configure-your-locale)

#### Set the default currency and locale

[](#set-the-default-currency-and-locale)

**Set the default options for currency and locale so that you don't have to set them for every field.**

**Option 1 (Recommended): Put the default options in your .env file.**

```
MONEY_DEFAULT_LOCALE=sv_SE
MONEY_DEFAULT_CURRENCY=SEK
```

**Option 2: Publish the config file and set the default options there.**

```
php artisan vendor:publish --provider="Pelmered\LaraPara\LaraParaServiceProvider" --tag="config"
```

#### Decimals and significant digits

[](#decimals-and-significant-digits)

The number of decimals and significant digits can be set in the config file. Defaults to 2.

```
//with input 123456
MONEY_DECIMAL_DIGITS=0 // Gives 0 decimals, e.g. $1,235
MONEY_DECIMAL_DIGITS=2 // Gives 2 decimals, e.g. $1,234.56
```

For significant digits, use negative values. For example -2 will give you 2 significant digits. This is only for displaying the amount. The amount will always be saved with full precision.

```
//with input 12345678
MONEY_DECIMAL_DIGITS=-2 // Gives 2 significant digits, e.g. $120,000
MONEY_DECIMAL_DIGITS=-4 // Gives 4 significant digits, e.g. $123,400
```

This can also be set on a per-field basis.

```
MoneyInput::make('price')->decimals(0);
MoneyEntry::make('price')->decimals(2);
MoneyColumn::make('price')->decimals(-2);
```

### Configuration for saving currency per field in database (Recommended, especially for multi-currency applications)

[](#configuration-for-saving-currency-per-field-in-database-recommended-especially-for-multi-currency-applications)

#### Migrations

[](#migrations)

Each money column needs a corresponding currency column with the name `{money_column_name}_currency`

For new columns

```
Schema::table('tablename', function (Blueprint $table) {
    $table->money('price'); // This will create two columns, 'price' (integer) and 'price_currency' (char(3))
});
```

For changing existing columns, in this case a column called `price`.

```
Schema::table('tablename', function (Blueprint $table) {
    $table->char('price_currency', 3)->after('price')->change();
    $this->index(['price', 'price_currency']);
});
```

Available column types(methods) on the Blueprint object are:

MethodWith int storageWith decimal storage`money()``BigInteger``Decimal(12, 3)``nullableMoney()``BigInteger (Nullable)``Decimal(12, 3) (Nullable)``smallMoney()``SmallInteger``Decimal(6, 3)``unsignedMoney()``BigInteger (Unigned)``Decimal(12, 3) (Unsigned)`Don't forget to run your migrations.

#### Casts

[](#casts)

Each money column should have a cast that casts the column to a Money object and the currency column should have a cast that casts the column to a Currency object

```
use Pelmered\LaraPara\Casts\CurrencyCast;
use Pelmered\LaraPara\Casts\MoneyCast;

protected function casts(): array
{
    return [
        'price' => MoneyCast::class,
        'price_currency' => CurrencyCast::class,
        'another_price' => MoneyCast::class,
        'another_price_currency' => CurrencyCast::class,
    ];
}
```

Or as a property:

```
protected $casts = [
    'price' => MoneyCast::class,
    'price_currency' => CurrencyCast::class,
    'another_price' => MoneyCast::class,
    'another_price_currency' => CurrencyCast::class,
];
```

This will give you value objects for the money and currency columns when you acceess them in your code. For example `$model->price` will get you a `\Money\Money` object. To access the amount you need to write `$model->price->getAmount()`. Currency columns gives you a `\Pelmered\LaraPara\Currencies\Currency` object, and to get the currency code as a string you need to write `$model->priceCurrency->getCode()`.

Value objects are great in most cases, but if you don't want to use them in your code, you can add an [accessor](https://laravel.com/docs/12.x/eloquent-mutators#accessors-and-mutators) for getting the raw values instead. This will cast your values to strings:

```
protected function price(): Attribute
{
    return Attribute::make(
        get: static fn (string $value) => $value
    );
}
protected function priceCurrency(): Attribute
{
    return Attribute::make(
        get: static fn (string $value) => $value,
    );
}
```

Usage
-----

[](#usage)

### Form

[](#form)

```
use Pelmered\LaraPara\Forms\Components\MoneyInput;

MoneyInput::make('price'); // Defaults to USD and the current Laravel locale, or what you have set in your .env/config.

MoneyInput::make('price')
    ->currency('USD')
    ->locale('en_US'),

MoneyInput::make('price')
    ->currency('SEK')
    ->locale('sv_SE'),

MoneyInput::make('price')
    ->currency('SEK')
    ->locale('sv_SE')
    ->minValue(0) // Do not allow negative values.
    ->maxValue(10000) // Add min and max value (in minor units, i.e. cents) to the input field. In this case no values over 100
    ->step(100) // Step value for the input field. In this case only multiples of 100 are allowed.
    ->decimals(0)
    ->getSymbolPlacement('after') // Possible options: 'after', 'before', 'none'. Defaults to 'before'
    ->hideCurrencySymbol() // Hide currency symbol.
    ->currencySwitcherEnabled() // Enable the currency switcher (if it is disabled globally in the config file).
    ->currencySwitcherDisabled() // Disable the currency switcher (if it is enabled globally in the config file).
```

### Table column

[](#table-column)

```
use Pelmered\LaraPara\Tables\Columns\MoneyColumn;

MoneyColumn::make('price'); // Defaults to USD and the current Laravel locale, or what you have set in your .env/config.

MoneyColumn::make('price')
    ->currency('USD')
    ->locale('en_US'),

MoneyColumn::make('price')
    ->currency('SEK')
    ->locale('sv_SE'),

MoneyColumn::make('price')
    ->short(), // Short format, e.g. $1.23M instead of $1,234,567.89

MoneyColumn::make('price')
    ->short()
    ->hideCurrencySymbol(), // Short format without currency symbol, e.g. 1.23M instead of $1.23M

MoneyColumn::make('price')
    ->decimals(4)
    ->short(), // $1.2345M

MoneyColumn::make('price')
    ->decimals(-3) // 3 significant digits
    ->short(), // $1.23K or $23.1M
```

### InfoList

[](#infolist)

```
use Pelmered\LaraPara\Infolists\Components\MoneyEntry;

MoneyEntry::make('price'); // Defaults to USD and the current Laravel locale, or what you have set in your .env/config.

// The default can be set in the Infolist class with:
public static string $defaultCurrency = 'SEK';

MoneyEntry::make('price')
    ->currency('USD')
    ->locale('en_US'),

MoneyEntry::make('price')
    ->currency('SEK')
    ->locale('sv_SE'),

MoneyEntry::make('price')
    ->short(), // Short fromat, e.g. $1.23M instead of $1,234,567.89
```

Global Configuration
--------------------

[](#global-configuration)

### If you want to use the formatting mask on the `MoneyInput` component

[](#if-you-want-to-use-the-formatting-mask-on-the-moneyinput-component)

**This will auto format the input field as you type.**

This is a bit experimental at the moment and is therefore disabled by default. Hopefully it will be improved in the future and enabled by default in the next major version. Please try it out and provide feedback.

```
MONEY_USE_INPUT_MASK=true // Defaults to false
```

### Use international currency codes (ISO 4217)

[](#use-international-currency-codes-iso-4217)

If you want to use international currency codes istead of their symbols or local short variants. For example USD instead of $, EUR instead of € or SEK instead of kr.

```
MONEY_INTL_CURRENCY_SYMBOL=true // Defaults to false
```

### Placement of currency symbol/code on input fields

[](#placement-of-currency-symbolcode-on-input-fields)

Possible options: `after`, `before`, `none`.

```
MONEY_UNIT_PLACEMENT=after // Defaults to before
```

### Decimals and significant digits

[](#decimals-and-significant-digits-1)

The number of decimals and significant digits can be set in the config file. Defaults to 2.

```
//with input 123456
MONEY_DECIMAL_DIGITS=0 // Gives 0 decimals, e.g. $1,235
MONEY_DECIMAL_DIGITS=2 // Gives 2 decimals, e.g. $1,234.56
```

For significant digits, use negative values. For example -2 will give you 2 significant digits.

```
//with input 12345678
MONEY_DECIMAL_DIGITS=-2 // Gives 2 significant digits, e.g. $120,000
MONEY_DECIMAL_DIGITS=-4 // Gives 4 significant digits, e.g. $123,400
```

This can also be set on a per-field basis.

```
MoneyInput::make('price')->decimals(0);
MoneyEntry::make('price')->decimals(2);
MoneyColumn::make('price')->decimals(-2);

// You can also pass a callback to the decimals method.
MoneyInput::make('price')->decimals(function () {
    return 0;
});
```

Roadmap / Ideas for the future
------------------------------

[](#roadmap--ideas-for-the-future)

Contact me or create an issue if you want something of this, or something else. I appreciate if you could tell me a bit about your use case for that feature as well.

- Currency conversions. Set what base currency the value in the database is and then convert to the current users preferred currency on the fly. Not sure how edit/create should be handled in this case.

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

[](#contributing)

I'm very happy to receive PRs with fixes or improvements. If it is a new feature, it is probably best to open an issue first, so I can give feedback and see if that is something I think would fit in this package. Especially if it is a larger feature, so you don't waste your time.

When you are submitting a PR, I appreciate if you:

- Add tests for your code. Not a strict requirement. Ask for guidance if you are unsure. I will try to help if I have time.
- Run the test suite and make sure it passes with `composer test`.
- Check the code with `composer lint`. This will run both PHPStan and Pint. See if you can address any issues there before submitting. You might also try to fix the code automatically with `composer fix`.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/680058?v=4)[Peter Elmered](/maintainers/pelmered)[@pelmered](https://github.com/pelmered)

---

Top Contributors

[![pelmered](https://avatars.githubusercontent.com/u/680058?v=4)](https://github.com/pelmered "pelmered (12 commits)")

### Embed Badge

![Health badge](/badges/pelmered-larapara/health.svg)

```
[![Health](https://phpackages.com/badges/pelmered-larapara/health.svg)](https://phpackages.com/packages/pelmered-larapara)
```

PHPackages © 2026

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