Track Who

Codacy BadgeStyleCILicenseTotal DownloadsLatest Stable Version

Create, update and delete authoring tracking dependency for Laravel Enso.

Details

  • 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

Use

  1. In the Model where you want to track the creating, updating or deleting user, add
use CreatedBy, UpdatedBy, DeletedBy;
  1. Make sure that the model's table has the created_by | updated_by | deleted_by field(s)

Configuration

The config/enso/trackWho.php configuration file, lets you customize the following:

  • resourcePersonAttributes:

    • 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.

Publishes

  • 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 --force flag

Notes

The traits will also define relationships with the User model so you can call $model->createdBy, $model->updatedBy, $model->deletedBy.

DeletedBy can be useful where you are using soft deletes.

The Laravel Enso Core package comes with this package included.

Last Updated: 11/12/2018, 4:35:32 PM