Download the PHP package devel8/laravel-action-tracker without Composer
On this page you can find all versions of the php package devel8/laravel-action-tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devel8/laravel-action-tracker
More information about devel8/laravel-action-tracker
Files in devel8/laravel-action-tracker
Package laravel-action-tracker
Short Description A simple package for tracking actions over models
License MIT
Informations about the package laravel-action-tracker
Laravel Action Tracker
This package provides an easy way to have an historical of actions done over models.
Installation
Execute the following command to get the latest version of the package:
Edit the config/app.php file and add the following line to register the service provider:
Run publish command to copy package configuration:
Finally, you will should run migration database command:
Usage
Use Devel8\LaravelActionTracker\ActionTrackerTrait
as trait in your model class:
Specify the actions done in the model, defining an actions
attribute in your model class:
Register an action done over a model executing doActionTracker
method as below:
Get the actions over a specific model:
Events
The Eloquent model method doActionTracker
dispatch a generic event in each action tracker registration.
You can listen this event adding the below code in your App\Providers\EventServiceProvider
:
Whether you prefer listen an action, you can add your custom event for each action adding it at the property actionEvents
in your Eloquent model as below:
ActionTracker send the Eloquent model ActionTracker
as argument to the constructor of your custom action event.
Therefore the event class looks like:
You can follow the official laravel documentation for further information about register events and listeners.
Configuration
You can configure some options as model, table name and columns name prefix:
Troubleshooting
Polymorphic relation
This package uses polymorphic relationship, so you can get troubles when you want to retrieve actions information by models.
By default Laravel saves model namespace in the database for relation model purpose. As namespaces have backslashes it could be a trouble when you filter by model.
To avoid this you can map model class names in your AppService Provider
:
All versions of laravel-action-tracker with dependencies
laravel/framework Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0.0|^7.0|^8.0|^9.0