leonardo-max/filament-js-money-field 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leonardo-max/filament-js-money-field

最新稳定版本:v4.0.0

Composer 安装命令:

composer require leonardo-max/filament-js-money-field

包简介

A Laravel Filament plugin for dynamic international currency masking using JavaScript Intl, supporting flexible currency and locale configuration via closures.

README 文档

README

Latest Version on Packagist Total Downloads

A Filament plugin for dynamic international currency masking using JavaScript Intl, supporting flexible currency and locale configuration via closures.

This plugin extends the functionality of a standard text field by adding a dynamic currency mask. All properties and behaviors of the standard field remain intact.

Supported Column Types

The plugin supports integer, decimal, double, and float. However, it is highly recommended to use integer or decimal for better precision and consistency when handling currency values.

If the column is of type integer, the entered value is stored as an integer, including the decimal cents, without any currency symbols or formatting.

Installation

You can install the package via composer:

composer require leonardo-max/filament-js-money-field

Usage

Form

use Tuxones\JsMoneyField\Forms\Components\JSMoneyInput;

JSMoneyInput::make('consumption_limit')
    ->currency('USD') // ISO 4217 Currency Code, example: USD
    ->locale('en-US') // BCP 47 Locale Code, example: en-US
    
// OR

JSMoneyInput::make('consumption_limit')
    ->hidden(fn (Get $get) => !$get('country'))
    ->currency(fn (Get $get) => $get('country') ? Country::find($get('country'))->currency : 'USD') 
    ->locale(fn (Get $get) => $get('country') ? Country::find($get('country'))->locale : 'en-US')

Table column

use Tuxones\JsMoneyField\Tables\Columns\JSMoneyColumn;

JSMoneyColumn::make('consumption_limit')
    ->currency('USD') // ISO 4217 Currency Code, example: USD
    ->locale('en-US') // BCP 47 Locale Code, example: en-US
    
// OR

JSMoneyColumn::make('consumption_limit')
    ->currency(fn (Model $record) => $record->country ? $record->country->currency : 'USD')
    ->locale(fn (Model $record) => $record->country ? $record->country->locale : 'en-US')

InfoList

use Tuxones\JsMoneyField\Infolists\Components\JSMoneyEntry;

JSMoneyEntry::make('consumption_limit')
    ->currency('USD') // ISO 4217 Currency Code, example: USD
    ->locale('en-US') // BCP 47 Locale Code, example: en-US
    
// OR

JSMoneyEntry::make('consumption_limit')
    ->currency(fn (Model $record) => $record->country ? $record->country->currency : 'USD')
    ->locale(fn (Model $record) => $record->country ? $record->country->locale : 'en-US')

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 58
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-05