Create, update and delete authoring tracking dependency for Laravel Enso.
- keeps track of the user that performed various actions on a record / model
- requires the presence of the proper model attributes / table columns
- once the structure is set up, by using the proper trait, the information is added automatically
- the trait works only when the user is authenticated, in order to avoid issues during tests or when using the cli/tinker
- In the Model where you want to track the creating, updating or deleting user, add
use CreatedBy, UpdatedBy, DeletedBy;
- Make sure that the model's table has the
config/enso/trackWho.php configuration file, lets you customize the following:
name, - string, the attribute used for name | default 'name'
appellative, - string, the attribute used for the person's appellative | default 'appellative'
These options are useful for customizing the person resource, when the people table has been updated for due to specific project requirements.
php artisan vendor:publish --tag=trackWho-config- configuration file
php artisan vendor:publish --tag=enso-config- a common alias for when wanting to update the configuration, once a newer version is released, usually used with the
The traits will also define relationships with the
User model so you can call
DeletedBy can be useful where you are using soft deletes.
The Laravel Enso Core package comes with this package included.