Cast attributes to Money objects
composer require brokeyourbike/money-casts-laravel
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',
];
}
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk