- Install the package via composer:
composer require --dev nova-horizons/realoquent
- Publish the config file:
php artisan vendor:publish --provider="NovaHorizons\Realoquent\RealoquentServiceProvider"
-
Review
config/realoquent.php
and adjust as needed. -
Run
php artisan realoquent:generate-schema
to generate your initial schema file.
This will examine your database schema and your Eloquent models to generate your startingschema.php
. You may need to revise the detected column types to have more accurate casts/PHPDocs. Some common things you may want to adjust:- Change any UUID columns from
ColumnType::string
toColumnType::uuid
(same for ULIDs) - For JSON columns, they may be detected as
ColumnType::longText
orColumnType::text
- Review any
ColumnType::tinyInt
orColumnType::boolean
columns to make sure the detected type is correct
See column types and generate-schema documentation for more details.
- Change any UUID columns from
-
Update your models with
php realoquent:generate-models
.
This will create a new base model class, and update your existing models to extend it. The Base Model will have the fillable/guarded/casts and PHP Docs automatically generated. These should never be manually modified.
All of your existing model logic will remain in the main model to keep your files clean and tidy.
See Model docs and generate-models documentation for more details. -
Commit your
schema.php
and updated models
Head to Usage to learn how to use Realoquent.