yurizoom / moonshine-currency
MoonShine 的货币字段
1.0.0
2024-05-03 00:41 UTC
Requires
- php: ^8.2
- ext-intl: *
- moonshine/moonshine: ^2.9
Conflicts
- moonshine/moonshine: <2.0
README
MoonShine 的货币字段。继承自 Number 字段。
安装
$ composer require yurizoom/moonshine-currency
设置
在 config/moonshine.php 文件中添加配置。
[ 'currency' => [ // Код валюты по-умолчанию (ISO 4217) 'default' => 'RUB', // Доступные коды валют. Используются, если код валюты хранится в БД 'currencies' => [ 'RUB', 'USD', 'EUR', ], ] ]
使用
在数据库中,货币单位以最小值存储。例如,100₽ = 10000。
显示时,值将除以 100。
use YuriZoom\MoonShineCurrency\Fields\Currency; Currency::make('Label');
指定存储货币代码的字段
use YuriZoom\MoonShineCurrency\Fields\Currency; Currency::make('Label')->currency('column');
货币代码应符合 ISO 4217 标准