Skip to content

Logic Repository Traits ​

These traits live in the Repositories\Logic namespace and are composed directly into the base Repository class. They are not opt-in — every repository gets them automatically. Together they provide the full infrastructure layer: query building, relationship hydration, lifecycle hooks, date normalisation, event dispatch, collation, caching, and timestamp management.

Trait Reference ​

TraitPurpose
QueryBuilderPaginated listing, single-record lookup, multi-ID fetching, and flat-list helpers
MethodTransformersLifecycle hook dispatcher — fans out to every {hookName}{Trait} method across loaded traits
RelationshipsSyncs all Eloquent relationship types (BelongsToMany, HasMany, MorphMany, MorphTo, MorphToMany) on save
RelationshipHelpersReflection-based relationship discovery and foreign key resolution
SchemaActive schema management and input chunking helpers
CountBuildersCached aggregate counts for status tabs (all, published, draft, trash)
DatesNormalises date fields to Y-m-d H:i:s before save
DispatchEventsDispatches domain events (create/update/delete/restore) after database commit
CollationSelectorApplies explicit MySQL collation to LIKE search queries on text columns
CacheableTraitRelationship-aware caching for index and record queries
InspectTraitsRuntime introspection — checks whether repository or model uses a given trait
TouchableEloquentModelDeferred updated_at touching — fires exactly once after all relationship syncs