Download the PHP package panoscape/tracker without Composer
On this page you can find all versions of the php package panoscape/tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tracker
Tracker
Eloquent CRUD records tracking for Laravel
Installation
You can install this package via composer
First, register service provider
config/app.php
Next, you may publish the config file with
Migration
Publish localization
Usage
Add Panoscape\Tracker\Context
trait to any model(s) you'd like to track.
Remember that you'll need to implement the abstract getContextLabel
method from the trait.
This will add the specified name value to the records.
Created new Project project_001
Context
A Context
is a model which is tracked on CURD actions. Like in User 001 Deleted Project 001
, Project 001
is the Context
we're talking about here.
To get all records of a contexted model
or via dynamic property
You may change the name of records
if you like(or to resolve method name conflicts)
Agent
An Agent
is a user who performs an action. Like in User 001 Deleted Project 001
, User 001
is the Agent
.
The agent in a record is always got from Auth
, thus the authorized user when the action is being performed.
You might have multiple user types in your application, and this package take well care of it.
To be able to getting related records from an agent, all you need is to add Panoscape\Tracker\Agent
trait to that model.
Get all records performed by an agent
or via dynamic property
You may change the name of records
if you like(or to resolve method name conflicts)
A record's agent might be null if it's tracked while unauthenticated
Record
The default strcuture of a record
Field | Type | Nullable |
---|---|---|
id | big unsigned integer | N |
context_id | unsigned integer | N |
context_type | string | N |
agent_id | unsigned integer | Y |
agent_type | string | Y |
message | string | N |
meta | text | Y |
performed_at | timestamp | N |
The message
filed is the action message in brief. examples
Created new Project my_project
Updating Project my_project
Deleting Project my_project
Restoring Project my_project
The meta
field is a json context of modified properties of a model. It's only available when the record is Updating ...
.
The performed_at
is a timestamp which indicates the moment the record is created, thus the moment the action being performed.
Get context of a record
or via dynamic property
Check agent of a record
Get agent of a record
or via dynamic property
The meta
property on Record is deserialized to an array, which hold the modification history
Localization
You may lolcalize the record output
This is the default localization
Simplified Chinese
The :context
is by default the class's base name.
To localize it, you can append a new language line to the localization file with the key being the class base name in snake case
The :name
is provided by getContextLabel
which we have mentioned above.
Configuration
Here is the default Configuration
To change the table hodling the records, set records_table
. Remember to update your migration after that.
To apply filters to operations, set operations
. Only operations in the list will be tracked.
To apply filters to agents, set agent_ignore
. Operations performed by agents in the list will NOT be tracked.
If you'd like to bypass an unauthenticated operation, add 'nobody'
to agent_ignore
.
If you need to bypass a specific agent type, add it's class name to agent_ignore
.