php 货币格式化,用于货币格式化和转换的Laravel包

Currency formatting and conversion package for Laravel.

68747470733a2f2f706f7365722e707567782e6f72672f616b61756e74696e672f6d6f6e65792f762f737461626c652e73766768747470733a2f2f706f7365722e707567782e6f72672f616b61756e74696e672f6d6f6e65792f642f746f74616c2e73766768747470733a2f2f7472617669732d63692e636f6d2f616b61756e74696e672f6d6f6e65792e73766768747470733a2f2f7374796c6563692e696f2f7265706f732f3131323132313530382f736869656c643f7374796c653d666c6174266272616e63683d6d617374657268747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616b61756e74696e672f6d6f6e65792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d617374657268747470733a2f2f706f7365722e707567782e6f72672f616b61756e74696e672f6d6f6e65792f6c6963656e73652e737667

This package intends to provide tools for formatting and conversion monetary values in an easy, yet powerful way for Laravel projects.

Why not use the moneyphp package?

Because moneyphp uses the intl extension for number formatting. intl extension isn't present by default on PHP installs and can give different results in different servers.

Getting Started

1. Install

Run the following command:

composer require akaunting/money

2. Register (for Laravel < 5.5)

Register the service provider in config/app.php

Akaunting\Money\Provider::class,

3. Publish

Publish config file.

php artisan vendor:publish --tag=money

4. Configure

You can change the currencies information of your app from config/money.php file

Usage

use Akaunting\Money\Currency;

use Akaunting\Money\Money;

echo Money::USD(500); // '$5.00' unconverted

echo new Money(500, new Currency('USD')); // '$5.00' unconverted

echo Money::USD(500, true); // '$500.00' converted

echo new Money(500, new Currency('USD'), true); // '$500.00' converted

Advanced

$m1 = Money::USD(500);

$m2 = Money::EUR(500);

$m1->getCurrency();

$m1->isSameCurrency($m2);

$m1->compare($m2);

$m1->equals($m2);

$m1->greaterThan($m2);

$m1->greaterThanOrEqual($m2);

$m1->lessThan($m2);

$m1->lessThanOrEqual($m2);

$m1->convert(Currency::GBP, 3.5);

$m1->add($m2);

$m1->subtract($m2);

$m1->multiply(2);

$m1->divide(2);

$m1->allocate([1, 1, 1]);

$m1->isZero();

$m1->isPositive();

$m1->isNegative();

$m1->format();

Helpers

money(500, 'USD')

currency('USD')

Blade Directives

@money(500, 'USD')

@currency('USD')

Changelog

Please see Releases for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email security@akaunting.com instead of using the issue tracker.

Credits

License

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值