brokeyourbike/money-casts-laravel

Cast attributes to Money object

1.0.4 2023-05-14 22:13 UTC

This package is auto-updated.

Last update: 2024-09-20 14:24:31 UTC


README

Latest Stable Version Total Downloads Maintainability Test Coverage

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

License

Mozilla Public License v2.0