Download the PHP package dual/kronikl without Composer
On this page you can find all versions of the php package dual/kronikl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package kronikl
Short Description A model history tracking library for Laravel.
License MIT
Informations about the package kronikl
Kronikl
A model history tracking library for Laravel.
Installation
Install the package via composer:
This will include Kronikl in your project. Now, publish the configuration file and the migration file:
Finally, run the migration:
NOTE: If you are using UUID primary keys, replace instances of
unsignedBigInteger
withuuid
before migrating.
Configuration
By default, create
, update
, delete
and restore
operations performed via Eloquent are observed. This means you do not need to call any other function, simply include the models you want to watch in the models
key in the configuration file (config/kronikl.php
).
Options are documented in config/kronikl.php
and are provided with sane defaults. Feel free to modify as needed.
By default, password
is defined in the discards
key for security purposes. Please do not remove this unless you know what you're doing.
Records
Audit trail records are saved in the kronikl_logs
table and is automatically created upon every successful created
, updated
and deleted
event monitored by an observer. Records are stored in JSON and can be searched via fuzzy search (using LIKE
direct in the record
column), or by using Laravel's whereJsonContains()
method for more specific results.
What does it look like?
The actual record is stored as JSON, so it's easy to do a json_decode()
on the record and call whatever record you want to use. For example:
On update, it only saves the fields that actually changed (and because we're using observers, calling
update()
with the same data won't record a new entry)
It's clean and coherent, you can modify your spiels to look however you want, since we only store the data and not how it's constructed. In JSON, it looks like the following (an example of a create
action log):
Discarding Data
Global Discards
You can discard a field name globally by setting it in config/kronikl.php
.
Model-specific Discards
In addition, if you want to discard a field specific to a model, you may add a public $discarded
declaration in your model:
Never store sensitive data in plaintext. Sane defaults have been provided (see config/kronikl.php
), adjust as necessary.
License
This library is published under the MIT Open Source license.