💰 The package provides money and currency features for a Laravel application.
You can install the package via composer:
composer require nevadskiy/laravel-money
Any field can be cast into Money
instance. To make it castable, add the following code to your model:
use Nevadskiy\Money\Casts\AsMoney;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'cost' => AsMoney::class.':UAH',
];
Schema::create('products', function (Blueprint $table) {
$table->bigInteger('cost')->unsigned();
$table->string('currency', 3);
});
use Nevadskiy\Money\Casts\AsMoney;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'cost' => AsMoney::class.':[currency]',
];
- use Symfony\Polyfill\Intl\Icu\Currencies for default registry