brokeyourbike / money-casts-laravel
Cast attributes to Money object
Fund package maintenance!
brokeyourbike
Open Collective
Requires
- php: ^8.0
- illuminate/contracts: ^8|^9
- moneyphp/money: ^4
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- illuminate/database: ^8|^9
- phpunit/phpunit: ^9.5
README
Cast attributes to Money objects
Installation
composer require brokeyourbike/money-casts-laravel
Usage
use Illuminate\Database\Eloquent\Model; use BrokeYourBike\MoneyCasts\CurrencyCast; use BrokeYourBike\MoneyCasts\MoneyCast; class Order extends Model { protected $casts = [ 'currency' => CurrencyCast::class . ':currency_code', 'amount' => MoneyCast::class . ':amount_in_cents,currency_code', ]; }
Authors
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk