Download the PHP package hasfoug/laravel-money without Composer
On this page you can find all versions of the php package hasfoug/laravel-money. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hasfoug/laravel-money
More information about hasfoug/laravel-money
Files in hasfoug/laravel-money
Package laravel-money
Short Description Laravel Money
License MIT
Homepage https://github.com/hasfoug/laravel-money
Informations about the package laravel-money
Laravel Money
Note: This project is based on cknow/laravel-money and abstracts MoneyPHP
Installation
Run the following command from you terminal:
Usage
Configuration
The defaults are set in config/money.php
. Copy this file to your own config directory to modify the values. You can publish the config using this command:
This is the contents of the published file:
Main changes to the cknow/laravel-money version:
Most operations now accept mixed values, parsing them to default currency before operation
Therefore, you are not required need to convert the operands to money instance anymore (unless you operate in non-default currency):
Added shortcuts for comparing operations
Added isNotZero accessor
getAmount() method return type switched to int
Added defaultSerializer to the config to set default json serialization behaviour
Change the value of money.defaultSerializer setting to one of those values:
- \Hasfoug\Money\Tests\Serializers\ArrayMoneySerializer::class
- \Hasfoug\Money\Tests\Serializers\DecimalMoneySerializer::class
- \Hasfoug\Money\Tests\Serializers\IntegerMoneySerializer::class
- \Hasfoug\Money\Tests\Serializers\StringMoneySerializer::class
Or create your own, which should implement \Hasfoug\Money\Contracts\MoneySerializer
Advanced Usage
See MoneyPHP for more information
Create your formatter
Rules
Below is a list of all available validation rules and their function:
currency
The field under validation must be a valid currency.
money
The field under validation must be a valid money.
Casts
At this stage the cast can be defined in the following ways:
In the example above, if the model attribute currency
is null
,
the currency defined in the package configuration is used instead.
Setting money can be done in several ways:
When we pass the model attribute holding the currency, such attribute is updated as well when setting money:
Helpers
Blade Extensions
All versions of laravel-money with dependencies
ext-json Version *
ext-intl Version *
illuminate/support Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/view Version ^7.0|^8.0|^9.0|^10.0|^11.0
moneyphp/money Version ^3.3|^4.0.3