ghonaim/filament-audit-logger

Production-ready audit & activity logger plugin for FilamentPHP v3 — tracks Eloquent model changes and admin panel user activity.

Maintainers

Package info

github.com/omarghonaim/FilamentPHP-Plugin

pkg:composer/ghonaim/filament-audit-logger

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-08-24 08:01 UTC

This package is not auto-updated.

Last update: 2026-08-25 00:04:51 UTC


README

Production-ready audit logging for FilamentPHP v3. Tracks Eloquent model create/update/delete/restore events and admin panel activity, zero external logging dependency.

Installation

composer require ghonaim/filament-audit-logger
php artisan vendor:publish --tag="filament-audit-migrations"
php artisan migrate
php artisan vendor:publish --tag="filament-audit-config"

Register the plugin in your panel provider:

use Ghonaim\FilamentAuditLogger\FilamentAuditLoggerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentAuditLoggerPlugin::make(),
        ]);
}

Usage

Attach the trait to any model you want tracked:

use Ghonaim\FilamentAuditLogger\Traits\HasFilamentAudit;

class Invoice extends Model
{
    use HasFilamentAudit;

    // Optional per-model overrides:
    protected array $auditEvents = ['created', 'updated', 'deleted', 'restored'];
    protected array $auditExclude = ['internal_notes'];
    protected array $auditInclude = []; // whitelist; empty = all attributes
}

Browse Audit Logs in the admin nav. Filter by user, action, model type, date range, IP. Click a row to open the diff view (old vs new values, side by side, changed fields highlighted).

Configuration

See config/filament-audit.php — retention window, critical actions, navigation placement, export disk, globally excluded attributes (password, tokens, etc. are stripped by default), and the authorization gate name (view-audit-logs).

Bind the gate in an AuthServiceProvider:

Gate::define('view-audit-logs', fn ($user) => $user->isAdmin());

Pruning

php artisan audit:prune                # uses config retention_days
php artisan audit:prune --days=30
php artisan audit:prune --dry-run

Auto-scheduled daily at 02:00 when prune.auto_schedule is true.

Export

Use the "Export" header action on the Audit Logs table (CSV/Excel). The export dispatches ExportAuditLogsJob onto the queue — configure QUEUE_CONNECTION for real async behavior; the file lands on the disk set in filament-audit.export.disk.

Customization

  • Swap the diff view: publish resources/views/vendor/filament-audit and edit components/diff-viewer.blade.php.
  • Add custom metadata per model by overriding auditMetadata().
  • Change the acting-user guard via filament-audit.user_guard.