Skip to content

Create Model Trait ​

Generate a reusable Eloquent model trait stub.

Command Information ​

  • Signature: modularous:make:model:trait {name}
  • Aliases: modularous:create:model:trait, mod:c:model:trait
  • Category: Generators

Arguments ​

ArgumentRequiredDescription
nameYesStudlyCase trait name (e.g. HasAnalytics → generates HasAnalyticsTrait.php)

What It Does ​

Creates a PHP trait file from a stub template with the StudlyCase name applied. Use this to extract reusable Eloquent behaviour (scopes, accessors, relationships) into a standalone trait that can be mixed into any model.

Examples ​

bash
php artisan modularous:make:model:trait HasAnalytics
php artisan mod:c:model:trait HasPricing

Output ​

Generates the trait file at:

Modules/{Module}/Traits/{StudlyName}Trait.php