Company
Date Published
Author
Shane Rosenthal
Word count
1391
Language
English
Hacker News points
None

Summary

$php artisan make:model Subscription -m` creates a model found at `app\Subscription.php` and a migration located at `database\migrations\create_subscriptions_table`. The migration adds columns for `id`, `price`, `currency`, and timestamps. A route is added to retrieve the first subscription, and a new cast class called `Money` is created to handle currency data. The `Money` class implements the `CastsAttributes` interface and provides methods for getting and setting the value of the `price` attribute as a Money object, with options to customize the amount and currency. The `Subscription` model is updated to use the `Money` cast on the `price` attribute.