Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aharen/laravel-money
Simple class with Facade to handle money for Laravel 5
https://github.com/aharen/laravel-money
Last synced: 3 days ago
JSON representation
Simple class with Facade to handle money for Laravel 5
- Host: GitHub
- URL: https://github.com/aharen/laravel-money
- Owner: aharen
- License: mit
- Created: 2016-08-11T07:46:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-21T04:52:47.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T13:01:59.917Z (4 months ago)
- Language: PHP
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-maldives - Laravel-money - Simple class with Facade to handle rufiyaa,laari for Laravel 5. (Table of Contents / PHP Projects)
README
# 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)
## Installation
composer require aharen/laravel-money
## Configuration
1. Add `MoneyServiceProvider` to `providers` in `config/app.php`
aharen\Money\MoneyServiceProvider::class,
2. Add `Money` Facade to `aliases` in `config/app.php`
Money => aharen\Money\MoneyManagerFacade::class,
## Usage
Initiate from either Rufiyaa
```php
$money = Money::fromRufiyaa(10);
```or Laari
```php
$money = Money::fromLaari(1000);
```### Addition
Expects the provided ammount to be added in Laari
```php
Money::fromRufiyaa(20)
->add(100) // 1 rufiyaa
->inRufiyaa();
```Adding other money objects
```php
Money::fromRufiyaa(20)
->add(Money::fromRufiyaa(20.5))
->inRufiyaa();
```### Subtraction
Expects the provided ammount to be subtracted in Laari
```php
Money::fromRufiyaa(20)
->subtract(100) // 1 rufiyaa
->inRufiyaa();
```Subtracting other money objects
```php
Money::fromRufiyaa(20)
->subtract(Money::fromRufiyaa(5)
->inRufiyaa();
```### Multiplication
Expects the provided ammount to be multiplied in Laari
```php
Money::fromRufiyaa(2)
->multiply(200) // 2 rufiyaa
->inRufiyaa();
```Multiplying other money objects
```php
Money::fromRufiyaa(20)
->multiply(Money::fromRufiyaa(5))
->inRufiyaa();
```### Division
Expects the provided ammount to be multiplied in Laari
```php
Money::fromRufiyaa(4)
->divide(200) // 2 rufiyaa
->inRufiyaa();
```Dividing other money objects
```php
Money::fromRufiyaa(4)
->divide(Money::fromRufiyaa(2))
->inRufiyaa();
```### Chaining Methods
You have the ability to manipulate the values in a chainable way.
```php
Money::fromRufiyaa(20)
->add(200) // 2 rufiyaa
->subtract(100) // 1 rufiyaa
->inRufiyaa();
```### Output
There are 3 output options available:
1. Output in Laari
```php
$money->inLaari();
```2. Output in Rufiyaa
```php
$money->inRufiyaa();
```3. Output in Rufiyaa and Laari
```php
$money->inRufiyaaAndLaari();
```