

GitHub - akaunting/money: Currency formatting and conversion package for Laravel
source link: https://github.com/akaunting/money
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Currency formatting and conversion package for Laravel
This package intends to provide tools for formatting and conversion monetary values in an easy, yet powerful way for Laravel projects.
Why not use the moneyphp
package?
Because it uses the intl
extension for number formatting. intl
extension isn't present by default on PHP installs and can give different results in different servers.
Getting Started
1. Install
Run the following command:
composer require akaunting/laravel-money
2. Publish
Publish config file.
php artisan vendor:publish --tag=money
3. Configure
You can change the currencies information of your app from config/money.php
file
Usage
use Akaunting\Money\Currency;
use Akaunting\Money\Money;
echo Money::USD(500); // '$5.00' unconverted
echo new Money(500, new Currency('USD')); // '$5.00' unconverted
echo Money::USD(500, true); // '$500.00' converted
echo new Money(500, new Currency('USD'), true); // '$500.00' converted
Advanced
$m1 = Money::USD(500);
$m2 = Money::EUR(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::GBP, 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, 'USD')
currency('USD')
Blade Directives
@money(500, 'USD')
@currency('USD')
Blade Component
Same as the directive, there is also a blade
component for you to create money and currency in your views:
<x-money amount="500" currency="USD" />
or
<x-money amount="500" currency="USD" convert />
<x-currency currency="USD" />
Changelog
Please see Releases for more information on what has changed recently.
Contributing
Pull requests are more than welcome. You must follow the PSR coding standards.
Security
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see LICENSE for more information.
Recommend
-
256
Akaunting™ Akaunting is a free, open source and online accounting software designed for small businesses and freelancers. It is built with modern technologies such as Laravel, VueJS, Bootstrap 4, RESTful API etc. Thanks to its modular str...
-
190
Persistent settings package for Laravel This package allows you to save settings in a more persistent way. You can use the database and/or json file to save your settings. You can also override the Laravel config. Driver supp...
-
104
Language switcher package for Laravel This package allows switching locale easily on Laravel projects. It's so simple to use, once it's installed, your App locale will change only by passing routes into SetLanguage middleware.
-
62
README.md Web Application Firewall (WAF) package for Laravel
-
8
Laravel Currency Laravel currency is a simple package for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host - no API keys need...
-
17
How to install Akaunting on Ubuntu 18.04Akaunting is a free, open source and online accounting software designed for small businesses and freelancers. This tool is built with modern technologies such as Laravel, Bootstrap, jQuery, RESTful API...
-
5
Hello there! Marc here again. I've just released a new Laravel package, this time it's about currencies. Almost in every project we have to format money in one or more formats, and personally, I've never remember how format with numbe...
-
7
Using a Different System? ...
-
3
<?xml encoding="utf-8" ??>Introduction Akaunting is a free, open-source accounting software based on PHP, used to manage financial-related tasks in a business, such as tracking invoices, payment...
-
9
Relative date computation and formatting This package allows to format the difference between two dates according to the value of their difference (expressed in seconds) or a symbolic relationship between the two dates (e.g. ‘today)....
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK