macromindonline/laravel-money

v2.2.0 2017-10-14 14:46 UTC

This package is not auto-updated.

Last update: 2024-12-11 03:51:05 UTC


README

Latest Stable Version Total Downloads License

StyleCI Build Status Build status Coverage Status

Code Climate Test Coverage Issue Count

Dependency Status Average time to resolve an issue Percentage of issues still open Gitter

SensioLabsInsight

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')