Download the PHP package pelmered/filament-money-field without Composer

On this page you can find all versions of the php package pelmered/filament-money-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-money-field

Filament Money Field

Money field powered by Money PHP.

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 License

Tests Test Coverage Type Coverage Complexity Crap PHPStan

Tested with Laravel 11 to 13 Tested on PHP 8.2 to 8.5 Tested on OS:es Linux, MacOS, Windows

Requirements

Key features

Are you using this package to make profits? Please consider sponsoring me.

Installation

Upgrade to 2. From 1.

See upgrade guide.

Configuration

Configure your 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.

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

Decimals and significant digits

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

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.

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

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

Migrations

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

For new columns

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

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

Method With int storage With 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

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

Or as a property:

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 for getting the raw values instead. This will cast your values to strings: `

The casts are required. MoneyInput writes a \Money\Money object to the attribute, and without a cast Eloquent passes that object straight to the query bindings, which fails with Object of class Money\Money could not be converted to string.

A Money object is also not a valid query binding, so pass the raw amount when you query:

Usage

Form

Table column

InfoList

Global Configuration

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.

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.

Placement of currency symbol/code on input fields

Possible options: after, before, none.

Decimals and significant digits

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

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

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

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.

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:

Test environments

The test suite can run against three dependency sets, each in its own vendor directory, so they can all stay installed at once. latest is the ordinary vendor/ from composer install, which is what composer test uses.

Environment Filament Laravel PHP Panel
lowest 4 11 8.3 http://127.0.0.1:8004/admin
middle 5 12 8.4 http://127.0.0.1:8006/admin
latest 5 13 8.5 http://127.0.0.1:8000/admin

lowest and middle are built by scripts/test-env.php, which generates their composer and PHPUnit config from the real composer.json and phpunit.xml, so an environment can never pin something the package does not support. Dependencies resolve for the environment's target PHP even if you don't have it installed, and the scripts print which version they actually ran on. lowest targets 8.3 rather than the package minimum of 8.2 because the Pest browser plugin requires 8.3; override with PHP_LOWEST or PHP_MIDDLE. These are the same three combinations the browser job in CI runs.

serve:* boots a workbench panel with no login, built on the same Post model as the tests. All three can run at once, and the panel title tells you which versions you are looking at — handy for checking that a change looks right everywhere.

Browser tests

The Browser test suite uses Pest browser testing to cover the behaviour that only exists once Livewire, Alpine and Filament's JavaScript have booted — client-side value hydration, currency symbol placement and the input mask.

It is not part of composer test, because it needs PHP 8.3+, Node and a Playwright browser:


All versions of filament-money-field with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-intl Version *
filament/support Version ^v4.0.0|^v5.0.0
moneyphp/money Version ^4.0
illuminate/support Version ^11.24 | ^12
php-static-analysis/attributes Version ^0.3.1 | ^0.4.0
pelmered/larapara Version dev-main
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pelmered/filament-money-field contains the following files

Loading the files please wait ...