Amended by 0133:
the HasUserStamps trait joins the trait table.
Context
Models opt into behaviour such as timestamps, delete policy, audit, search and encryption (0046). Each package that adds behaviour to a model or another class needs a name for it that tells a reader what it does. Laravel’s mix of traits and “concerns” with inconsistent names is the example to avoid.Decision
-
Reusable class behaviour is a trait, created with
createTraitfrom@stackra/model. There are no “concerns”. -
Names follow one grammar:
-
SoftDeletesis the one exception, kept for recognition. -
The trait list, each owned by one package:
- A new trait is added to this list in the change that creates it.
Consequences
- A trait’s name tells a reader whether it adds columns, exposes a capability, or adapts a role.
@stackra/modelowns the trait registry, so traits from many packages compose on one class.- Which package owns
Auditableis the least certain row: audit is a service fed by events, and the trait only publishes.
Enforcement
Planned: a lint rule that everycreateTrait call’s name matches the grammar or is SoftDeletes, and a test that every trait
is listed in this page’s table. Nothing checks this today.