General Configuration
The default auditing behavior can be altered by updating the settings in the configuration file, which can be found in config/audit.php
.
Audit implementation
Since version 4.1.0, the audit implementation can be configured.
By default, the package will use OwenIt\Auditing\Models\Audit
.
return [
// ...
'implementation' => OwenIt\Auditing\Models\Audit::class,
// ...
];
Read more about it in the Audit Implementation section.
User Keys & Model
Specify the User
keys and model.
Primary and Foreign Keys
Sometimes, for whatever reason (legacy database, etc), a different key needs to be used.
The default primary and foreign key values are id
and user_id
, respectively.
return [
// ...
'user' = [
'primary_key' => 'id',
'foreign_key' => 'user_id',
],
// ...
];
{note} The
Audit
resolveData() method will still useuser_id
and otheruser_
prefixed keys for anyUser
data, regardless of the foreign key that was set.
Model
The model value should be set to the FQCN of the User
class used by the application.
return [
// ...
'user' = [
'model' => App\User::class,
],
// ...
];
Audit driver
Being the only driver provided, the Database
driver is set as default.
return [
// ...
'driver' => 'database',
// ...
];
The Database
driver allows modifying:
- The database connection.
- The table where the
Audit
records are stored.
return [
// ...
'drivers' => [
'database' => [
'table' => 'audits',
'connection' => null,
],
],
// ...
];
Console/CLI and Jobs
Eloquent events fired from a Job or from the console (i.e. migrations, tests, commands, Tinker, ...), WILL NOT be audited by default.
To enable console auditing, set the console
value to true
.
return [
// ...
'console' => true,
// ...
];
{note} Resolving a
User
in the console may not work.