Appearance
UserAuditable
Purpose
Adds model event hooks that fill audit columns from the current authenticated user.
Expected Columns
The trait is designed for models that may have:
created_byupdated_bydeleted_by
If some columns do not exist, the trait safely skips those paths.
Boot Behavior
bootUserAuditable() hooks into:
creatingupdatingdeleting
Behavior:
- fills
created_bywhen creating - fills
updated_bywhen updating - fills
deleted_bywhen deleting
Guard Resolution
getUserAuditableGuard()
Returns the default auth guard from config.
getUserAuditableProvider()
Returns the model class associated with the current auditable guard.
Relationships
The trait also provides:
createdBy()updatedBy()deletedBy()
Each returns a belongsTo relation when the provider model can be resolved.