Skip to content

make:model ​

Create an Eloquent model for a module

Signature: modularous:make:model

Alias: mod:m:model

Category: Make


Description ​

Generates an Eloquent model class with optional trait composition, relationship methods, and fillable fields. When traits like addTranslation or addSlug are enabled, companion models ({Name}Translation, {Name}Slug) are automatically created alongside the main model. When --relationships is provided, many-to-many pivot models are also created.


Usage ​

modularous:make:model [options] <model> [<module>]

Arguments ​

ArgumentRequiredDescription
modelyesModel class name (e.g. Post, ProductVariant)
modulenoTarget module; omit to create in app/Models/

Options ​

OptionShortDescription
--fillable=Comma-separated fillable field names
--relationships=Relationship definition string
--override-model=Fully-qualified base class to extend instead of the default
--selfWrite to the Modularous vendor path
--force-fOverwrite existing files
--soft-delete-sAdd SoftDeletes trait
--has-factoryAdd HasFactory trait and newFactory() method
--no-defaultsSkip Modularous default fillable fields
--notAskSkip interactive trait questions
--allAccept all trait questions
--testDry-run / preview mode

Trait flags ​

OptionShortDescription
--addTranslation-TCreates a {Name}Translation companion model
--addMedia-MAttach HasMedia trait
--addFile-FAttach HasFile trait
--addPosition-PAttach HasPosition trait
--addSlug-SCreates a {Name}Slug companion model
--addAuthorized-AAttach authorization scope trait
--addFilepond-FPAttach FilePond trait
--addUuidUse UUID primary key
--addSnapshot-SSAttach snapshot/versioning trait
--addPriceAttach pricing trait

Examples ​

Basic model for a module ​

bash
php artisan modularous:make:model Post Blog

Model with fillable and soft-delete ​

bash
php artisan modularous:make:model Post Blog \
    --fillable="title,body,published_at" \
    --soft-delete

Translatable model with media ​

bash
php artisan modularous:make:model Post Blog --addTranslation --addMedia

Standalone model in app/Models (no module) ​

bash
php artisan modularous:make:model Article

Preview without writing ​

bash
php artisan modularous:make:model Post Blog --test

Output files ​

ConditionFile created
Always{Module}/Entities/Post.php
--addTranslation{Module}/Entities/Translations/PostTranslation.php
--addSlug{Module}/Entities/Slugs/PostSlug.php
--relationships (BelongsToMany)Pivot model(s) in {Module}/Entities/

See also ​