@@ -6,6 +6,7 @@ Lightweight object logging for CodeIgniter 4
661 . Install with Composer: ` > composer require tatter/audits `
772 . Update the database: ` > php spark migrate -all `
883 . Setup your models:
9+
910```
1011class JobModel extends Model
1112{
@@ -14,7 +15,7 @@ class JobModel extends Model
1415 protected $afterUpdate = ['auditUpdate'];
1516 protected $afterDelete = ['auditDelete'];
1617```
17- 4 . All done!
18+
1819
1920## Features
2021
@@ -33,45 +34,35 @@ Once the files are downloaded and included in the autoload, run any library migr
3334to ensure the database is setup correctly:
3435* ` > php spark migrate -all `
3536
36- ** Pro Tip:** You can add the spark command to your composer.json to ensure your database is
37- always current with the latest release:
38- ```
39- {
40- ...
41- "scripts": {
42- "post-update-cmd": [
43- "composer dump-autoload",
44- "php spark migrate -all"
45- ]
46- },
47- ...
48- ```
49-
5037## Configuration (optional)
5138
5239The library's default behavior can be altered by extending its config file. Copy
53- ** bin /Audits.php** to ** app/Config/Audits.php** and follow the instructions in the
40+ ** examples /Audits.php** to ** app/Config/Audits.php** and follow the instructions in the
5441comments. If no config file is found in ** app/Config** the library will use its own.
5542
5643## Usage
5744
5845Once the library is included all the resources are ready to go and you just need to
5946specify which models and events to audit. Use AuditsTrait to add support to any models
6047you would like tracked:
48+
6149```
6250class JobModel extends Model
6351{
6452 use \Tatter\Audits\Traits\AuditsTrait;
6553```
54+
6655Then specify which events you want audited by assigning the corresponding audit methods
6756for those events:
57+
6858```
6959 protected $afterInsert = ['auditInsert'];
7060 protected $afterUpdate = ['auditUpdate'];
7161 protected $afterDelete = ['auditDelete'];
7262```
7363
7464The Audits library will create basic logs of each event in the ` audits ` table, for example:
65+
7566```
7667| id | source | source_id | user_id | event | summary | created_at |
7768+----+--------+-----------+---------+--------+----------+---------------------+
0 commit comments