macromindonline / laravel-money
Laravel Money
v2.2.0
2017-10-14 14:46 UTC
Requires
- php: ~7.0
- ext-intl: *
- illuminate/support: ~5.5
- illuminate/view: ~5.5
- moneyphp/money: ~3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.7
- graham-campbell/testbench: ~4.0
- jakub-onderka/php-parallel-lint: ~0.9
- mockery/mockery: ~1.0
- nikic/php-parser: ~3.1
- phpmd/phpmd: ~2.6
- phpro/grumphp: ~0.12
- phpstan/phpstan: ~0.8
- phpunit/phpunit: ~6.0
- povils/phpmnd: ~1.1
- sebastian/phpcpd: ~3.0
- sensiolabs/security-checker: ~4.1
- squizlabs/php_codesniffer: ~3.1
README
Note: This project abstracts MoneyPHP
Installation
Run the following command from you terminal:
composer require cknow/laravel-money
or add this to require section in your composer.json file:
"cknow/laravel-money": "~2.0"
then run composer update
Usage
use Cknow\Money\Money; echo Money::BRL(500); // R$5,00
Advanced Usage
See MoneyPHP for more information
use Cknow\Money\Money; Money::BRL(500)->add(Money::BRL(500)); // 10,00 Money::BRL(500)->subtract(Money::BRL(400)); // 1,00 Money::BRL(500)->isZero(); // false Money::BRL(500)->isPositive(); // true Money::BRL(500)->isNegative(); // false Money::BRL(500)->format(); // R$5,00 Money::BRL(500)->formatByDecimal(); // 5.00 Money::parse('R$1,00'); // R$1,00 -> Money::BRL(100) Money::parseByDecimal('1.00', 'BRL'); // R$1,00 -> Money::BRL(100)
Helpers
currency('BRL') money(500, 'BRL') money_parse('R$5,00')
Blade Extensions
@currency('BRL') @money(500, 'BRL') @money_parse('R$5,00')