2017 © Pedro Peláez
 

library laravel-money

Simple class with Facade to handle money for Laravel 5.2

image

aharen/laravel-money

Simple class with Facade to handle money for Laravel 5.2

  • Thursday, March 9, 2017
  • by aharen
  • Repository
  • 1 Watchers
  • 0 Stars
  • 58 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Laravel Money

Simple class with Facade to handle money for Laravel 5. The class stores and calculates all money related value (eg: prices etc..) in Laari (Pennies), (*1)

Installation

composer require aharen/laravel-money

Configuration

  1. Add MoneyServiceProvider to providers in config/app.php, (*2)

    aharen\Money\MoneyServiceProvider::class,, (*3)

  2. Add Money Facade to aliases in config/app.php, (*4)

    Money => aharen\Money\MoneyManagerFacade::class,, (*5)

Usage

Initiate from either Rufiyaa, (*6)

$money = Money::fromRufiyaa(10);

or Laari, (*7)

$money = Money::fromLaari(1000);

Addition

Expects the provided ammount to be added in Laari, (*8)

Money::fromRufiyaa(20)
         ->add(100) // 1 rufiyaa
         ->inRufiyaa();

Adding other money objects, (*9)

Money::fromRufiyaa(20)
         ->add(Money::fromRufiyaa(20.5))
         ->inRufiyaa();

Subtraction

Expects the provided ammount to be subtracted in Laari, (*10)

Money::fromRufiyaa(20)
         ->subtract(100) // 1 rufiyaa
         ->inRufiyaa();

Subtracting other money objects, (*11)

Money::fromRufiyaa(20)
         ->subtract(Money::fromRufiyaa(5)
         ->inRufiyaa();

Multiplication

Expects the provided ammount to be multiplied in Laari, (*12)

Money::fromRufiyaa(2)
      ->multiply(200) // 2 rufiyaa
      ->inRufiyaa();

Multiplying other money objects, (*13)

Money::fromRufiyaa(20)
       ->multiply(Money::fromRufiyaa(5))
       ->inRufiyaa();

Division

Expects the provided ammount to be multiplied in Laari, (*14)

Money::fromRufiyaa(4)
       ->divide(200) // 2 rufiyaa
       ->inRufiyaa();

Dividing other money objects, (*15)

Money::fromRufiyaa(4)
       ->divide(Money::fromRufiyaa(2))
       ->inRufiyaa();

Chaining Methods

You have the ability to manipulate the values in a chainable way., (*16)

Money::fromRufiyaa(20)
       ->add(200) // 2 rufiyaa
       ->subtract(100) // 1 rufiyaa
       ->inRufiyaa();

Output

There are 3 output options available:, (*17)

  1. Output in Laari
    $money->inLaari();
  1. Output in Rufiyaa
   $money->inRufiyaa();
  1. Output in Rufiyaa and Laari
    $money->inRufiyaaAndLaari();

The Versions

09/03 2017

dev-master

9999999-dev

Simple class with Facade to handle money for Laravel 5.2

  Sources   Download

MIT

The Requires

 

by Ahmed Khusaam

laravel money

09/03 2017

v1.0.0

1.0.0.0

Simple class with Facade to handle money for Laravel 5.2

  Sources   Download

MIT

The Requires

 

by Ahmed Khusaam

laravel money