Giter VIP home page Giter VIP logo

laravel-money's Introduction

Laravel Money

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Latest Stable Version License

Installation

Run the following command from you terminal:

composer require cknow/laravel-money:~0.1.0

or add this to require section in your composer.json file:

"cknow/laravel-money": "~0.1.0"

then run composer update

In your config/app.php add 'ClickNow\Money\MoneyServiceProvider' to the end of the 'providers' array:

'providers' => array(
    ...
    ...
    ClickNow\Money\MoneyServiceProvider::class,
),

Usage

use ClickNow\Money\Money;

echo Money::BRL(500); // 'R$ 5,00' unconverted
echo new Money(500, new Currency('BRL')); // 'R$ 5,00' unconverted
echo Money::BRL(500, true); // 'R$ 500,00' converted
echo new Money(500, new Currency('BRL'), true); // 'R$ 500,00' converted

Advanced Usage

var $m1 = Money::BRL(500);
var $m2 = Money::BRL(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::USD, 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, 'BRL')
currency('BRL')

Blade Extensions

@money(500, 'BRL')
@currency('BRL')

laravel-money's People

Contributors

ricardogobbosouza avatar wiledia avatar kurre avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.