PHP code example of ghonaim / filament-audit-logger

1. Go to this page and download the library: Download ghonaim/filament-audit-logger 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/ */

    

ghonaim / filament-audit-logger example snippets


use Ghonaim\FilamentAuditLogger\FilamentAuditLoggerPlugin;

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

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
}

Gate::define('view-audit-logs', fn ($user) => $user->isAdmin());
bash
composer vendor:publish --tag="filament-audit-migrations"
php artisan migrate
php artisan vendor:publish --tag="filament-audit-config"
bash
php artisan audit:prune                # uses config retention_days
php artisan audit:prune --days=30
php artisan audit:prune --dry-run