1. Go to this page and download the library: Download dineshstack/laravel-audit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dineshstack / laravel-audit example snippets
use Dineshstack\LaravelAudit\Traits\LogsActivity;
class Invoice extends Model
{
use LogsActivity;
}
class User extends Model
{
use LogsActivity;
// Never log these columns
protected function getAuditExclude(): array
{
return ['updated_at', 'created_at', 'remember_token', 'two_factor_secret'];
}
// Log ONLY these columns (overrides exclude; empty = log all minus excluded)
protected function getAuditInclude(): array
{
return ['name', 'email', 'role'];
}
}
return [
// Bearer token protecting the REST API (leave empty to disable auth)
'token' => env('AUDIT_TOKEN', ''),
// Prune logs older than this many days
'retention_days' => env('AUDIT_RETENTION_DAYS', 90),
// Fields redacted in stored diffs (case-insensitive substring match)
'masked_fields' => ['password', 'token', 'secret', 'api_key',
'card_number', 'cvv', 'ssn', 'remember_token'],
// Default alert thresholds (overridden by DB rules per event pattern)
'alert_thresholds' => [
'deletes_per_min' => 10,
'logins_per_min' => 20,
'exports_per_hour' => 5,
'updates_per_min' => 50,
],
// Active notification channels
'alert_channels' => ['email', 'slack'],
// Mailgun + Slack credentials
'alerts' => [
'email' => [
'mailgun_key' => env('AUDIT_MAILGUN_API_KEY'),
'mailgun_domain' => env('AUDIT_MAILGUN_DOMAIN'),
'from' => env('AUDIT_ALERT_FROM', '[email protected]'),
'to' => env('AUDIT_ALERT_TO'),
],
'slack' => [
'webhook_url' => env('AUDIT_SLACK_WEBHOOK_URL'),
],
],
];