Laravel Money is a composer package by Ricardo Gobbo de Souza for working with and formatting money in Laravel projects.
Laravel money uses the moneyphp/money PHP package under the hood and gives you a bunch of helpers:
1use Cknow\Money\Money;23echo Money::USD(500); // $5.00
This package includes a ton of advanced features for doing money operations, comparisons, aggregations, formatting, and parsing:
1// Basic operations 2Money::USD(500)->add(Money::USD(500)); // $10.00 3Money::USD(500)->subtract(Money::USD(400)); // $1.00 4 5// Aggregation 6Money::min(Money::USD(100), Money::USD(200), Money::USD(300)); // Money::USD(100) 7 8// Formatters 9Money::USD(500)->format(); // $5.001011// Parsers12Money::parse('$1.00'); // Money::USD(100)
You can also create a custom formatter for your specific use-case:
1Money::USD(500)->formatByFormatter(new MyFormatter());
Be sure to check out the advanced usage and included helper functions in the project’s README file. Also, check out the Money PHP documentation for complete details of what this package is capable of doing.
You can learn more about this package and check out the source code on GitHub at cknow/laravel-money.
0 comments:
Post a Comment
Thanks