Git Product home page Git Product logo

laravel-money's Introduction

Laravel Money

Latest Stable Version Total Downloads License

StyleCI Build Status Build status Coverage Status

Code Climate Test Coverage Issue Count

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": "~3.1"

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(199)->format(null, null, \NumberFormatter::DECIMAL); // 1,99
Money::BRL(500)->formatByDecimal(); // 5.00
Money::BRL(830)->mod(Money::BRL(300)); // R$2,30 -> Money::BRL(230)
Money::BRL(30)->ratioOf(Money::BRL(2)); // 15
Money::parse('R$1,00'); // R$1,00 -> Money::BRL(100)
Money::parseByDecimal('1.00', 'BRL'); // R$1,00 -> Money::BRL(100)

Create your formatter

class MyFormatter implements \Money\MoneyFormatter
{
    public function format(\Money\Money $money)
    {
        return 'My Formatter';
    }
}

Money::BRL(500)->formatByFormatter(new MyFormatter());

Helpers

currency('BRL')
money(500, 'BRL')
money_parse('R$5,00')
money_parse_by_decimal('1.00', 'BRL')

Blade Extensions

@currency('BRL')
@money(500, 'BRL')
@money_parse('R$5,00')
@money_parse_by_decimal('1.00', 'BRL')

laravel-money's People

Contributors

ricardogobbosouza avatar russofinn avatar kurre avatar

Stargazers

 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.