{"id":50000529,"url":"https://github.com/TappNetwork/filament-auditing","last_synced_at":"2026-06-05T01:00:43.907Z","repository":{"id":57749764,"uuid":"524801285","full_name":"TappNetwork/filament-auditing","owner":"TappNetwork","description":"A Filament plugin for Laravel Auditing package. ","archived":false,"fork":false,"pushed_at":"2026-04-26T18:39:08.000Z","size":3317,"stargazers_count":114,"open_issues_count":17,"forks_count":40,"subscribers_count":5,"default_branch":"4.x","last_synced_at":"2026-04-26T20:28:47.098Z","etag":null,"topics":["audit","auditing","filament","hacktoberfest","hacktoberfest2022","laravel","php","plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TappNetwork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-08-14T23:20:31.000Z","updated_at":"2026-04-26T18:39:13.000Z","dependencies_parsed_at":"2024-03-14T21:30:49.900Z","dependency_job_id":"8186597e-c6cd-498f-9aa4-767f47e2e3a5","html_url":"https://github.com/TappNetwork/filament-auditing","commit_stats":{"total_commits":18,"total_committers":4,"mean_commits":4.5,"dds":"0.38888888888888884","last_synced_commit":"d373709008ea3995542fd3c3dfacaf855bbc50a2"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/TappNetwork/filament-auditing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-auditing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-auditing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-auditing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-auditing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TappNetwork","download_url":"https://codeload.github.com/TappNetwork/filament-auditing/tar.gz/refs/heads/4.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-auditing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33926275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit","auditing","filament","hacktoberfest","hacktoberfest2022","laravel","php","plugin"],"created_at":"2026-05-19T12:00:26.529Z","updated_at":"2026-06-05T01:00:43.898Z","avatar_url":"https://github.com/TappNetwork.png","language":"PHP","funding_links":[],"categories":["Plugins"],"sub_categories":["Administration \u0026 Management"],"readme":"# Filament Laravel Auditing\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tapp/filament-auditing.svg?style=flat-square)](https://packagist.org/packages/tapp/filament-auditing)\n![Code Style Action Status](https://github.com/TappNetwork/filament-auditing/actions/workflows/fix-php-code-style-issues.yml/badge.svg)\n[![Total Downloads](https://img.shields.io/packagist/dt/tapp/filament-auditing.svg?style=flat-square)](https://packagist.org/packages/tapp/filament-auditing)\n\nA Filament plugin for [Laravel Auditing](https://laravel-auditing.com/) package.\nThis plugin contains a relation manager for audits that you can add to your Filament resources.\n\nThis package provides a Filament resource manager that shows a table with all audits on view and edit pages and allows\nrestore audits.\n\n## Version Compatibility\n\n Filament | Filament Auditing | Documentation\n:---------|:-----------------|:--------------\n| 4.x/5.x | 4.x              | Current\n| 3.x     | 3.x              | [Check the docs](https://github.com/TappNetwork/filament-auditing/tree/3.x)\n| 2.x     | 2.x              | [Check the docs](https://github.com/TappNetwork/filament-auditing/tree/2.x)\n\n## Installation\n\n\u003e [!IMPORTANT]\n\u003e Please check the **Filament Auditing** plugin version you should use in the **Version Compatibility** table above.\n\n\u003e **Note**\n\u003e This plugin uses the [Laravel Auditing](https://laravel-auditing.com/) package. First install and configure this\n\u003e package.\n\nYou can install the plugin via Composer.\n\n```bash\ncomposer require tapp/filament-auditing:\"^4.0\"\n```\n\nYou can publish the view files with:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-auditing-views\"\n```\nYou can publish the translation files with:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-auditing-translations\"\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-auditing-config\"\n```\n\nThis is the content of the published config file:\n\n```php\n\u003c?php\n\nuse Tapp\\FilamentAuditing\\Filament\\Resources\\Audits\\AuditResource;\n\nreturn [\n\n    'audits_sort' =\u003e [\n        'column' =\u003e 'created_at',\n        'direction' =\u003e 'desc',\n    ],\n\n    'is_lazy' =\u003e true,\n\n    'grouped_table_actions' =\u003e false,\n\n    /**\n     *  Extending Columns\n     * --------------------------------------------------------------------------\n     *  In case you need to add a column to the AuditsRelationManager that does\n     *  not already exist in the table, you can add it here, and it will be\n     *  prepended to the table builder.\n     */\n    'audits_extend' =\u003e [\n        // 'url' =\u003e [\n        //     'class' =\u003e \\Filament\\Tables\\Columns\\TextColumn::class,\n        //     'methods' =\u003e [\n        //         'sortable',\n        //         'searchable' =\u003e true,\n        //         'default' =\u003e 'N/A'\n        //     ]\n        // ],\n    ],\n\n    'custom_audits_view' =\u003e false,\n\n    'custom_view_parameters' =\u003e [\n    ],\n\n    'mapping' =\u003e [\n    ],\n\n    'resources' =\u003e [\n        'AuditResource' =\u003e AuditResource::class,\n    ],\n\n];\n\n```\n\n`audits_sort`: can be used to change the default sort on the audits table.\n\n`grouped_table_actions`: set to true to group the actions on the audits table.\n\n### Multi-Tenancy Support\n\nThis plugin supports multi-tenancy for Filament applications. When enabled, all audit records are automatically scoped to the current tenant, ensuring that users only see audits belonging to their tenant.\n\n#### Configuration\n\nTo enable tenancy support, update your `config/filament-auditing.php` file:\n\n```php\n'tenancy' =\u003e [\n    // Enable tenancy support\n    'enabled' =\u003e true,\n\n    // The Tenant model class (e.g., App\\Models\\Team::class, App\\Models\\Organization::class)\n    'model' =\u003e \\App\\Models\\Team::class,\n\n    // The tenant relationship name (defaults to snake_case of tenant model class name)\n    // For example: Team::class -\u003e 'team', Organization::class -\u003e 'organization'\n    // This should match what you configure in your Filament Panel:\n    // -\u003etenantOwnershipRelationshipName('team')\n    'relationship_name' =\u003e 'teams',\n\n    // The tenant column name (defaults to snake_case of tenant model class name + '_id')\n    // You can override this if needed\n    'column' =\u003e 'team_id',\n],\n```\n\n#### Migration\n\nAfter enabling tenancy, you need to publish and run the migration to add the tenant column to the `audits` table.\n\nFirst, publish the migration:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-auditing-migrations\"\n```\n\nThen, run the migration:\n\n```bash\nphp artisan migrate\n```\n\nThe migration will automatically add the configured tenant column (e.g., `team_id`) to the `audits` table with a foreign key constraint.\n\n\u003e **Note**: The tenant resolver is automatically registered by the plugin's service provider. You do **not** need to manually add it to your `config/audit.php` file's `resolvers` array. The plugin handles this automatically when tenancy is enabled.\n\n#### How It Works\n\nWhen tenancy is enabled:\n\n1. **Automatic Tenant Assignment**: New audit records are automatically assigned to the current tenant using Laravel Auditing's resolver system. The plugin automatically registers a custom resolver that gets the current tenant from Filament and sets it on new audit records.\n\n2. **Query Scoping**: All audit queries are automatically scoped to the current tenant:\n   - The AuditResource list page only shows audits for the current tenant\n   - The ViewAudit page only allows viewing audits belonging to the current tenant\n   - The AuditsRelationManager only shows audits for the current tenant\n\n3. **Security**: The restore action validates that the audit belongs to the current tenant before allowing restoration, preventing cross-tenant data access.\n\n#### Important Notes\n\n- **Enable Before Migrations**: Make sure to enable tenancy in your config file before running migrations. The migration checks the config to determine whether to add the tenant column.\n\n- **Panel Configuration**: Ensure your Filament panel is configured with tenancy. For example, in your `AppPanelProvider`:\n\n```php\n-\u003etenant(Team::class, slugAttribute: 'slug')\n-\u003etenantDomain('{tenant:slug}.'.$host)\n```\n\n- **Existing Audits**: If you enable tenancy after audits have already been created, existing audits will have `null` for the tenant column. You may need to backfill this data manually if required.\n\n### Integrate Filament Auditing Tailwind classes\n\nFilament recommends developers create a custom theme to better support plugin's additional Tailwind classes. After you have created your custom theme, add the Filament Auditing vendor path to your `theme.css` file, usually located in `resources/css/filament/admin/theme.css`:\n\n```css\n@import '../../../../vendor/filament/filament/resources/css/theme.css';\n\n@source '../../../../app/Filament';\n@source '../../../../resources/views/filament';\n@source '../../../../vendor/tapp/filament-auditing'; // Add this line\n```\n\n## Usage\n\nTo show the audits table in your Filament resource, just add `AuditsRelationManager::class` on your\nresource's `getRelations` method:\n\n```php\nuse Tapp\\FilamentAuditing\\RelationManagers\\AuditsRelationManager;\n\npublic static function getRelations(): array\n{\n    return [\n        // ...\n        AuditsRelationManager::class,\n    ];\n}\n```\n\nTo show the Audit resource in navigation menu, add to your panel provider, e.g. `AdminPanelProvider.php`:\n\n```php\nuse Tapp\\FilamentAuditing\\FilamentAuditingPlugin;\n\nreturn $panel\n    -\u003eplugins([\n        FilamentAuditingPlugin::make(),\n    ]);\n```\n\nThat's it, you're all set!\n\nIf you access your resource, and edit some data, you will now see the audits table on edit and view pages.\n\n## Appareance\n\nRelation Manager\n\n![Filament Audit Relation Manager](https://raw.githubusercontent.com/TappNetwork/filament-auditing/4.x/art/relation_manager.png)\n\nResource\n\n![Filament Audit Resource](https://raw.githubusercontent.com/TappNetwork/filament-auditing/4.x/art/resource.png)\n\nView Audit\n\n![Filament Audit Resource](https://raw.githubusercontent.com/TappNetwork/filament-auditing/4.x/art/infolist1.png)\n\n![Filament Audit Resource](https://raw.githubusercontent.com/TappNetwork/filament-auditing/4.x/art/infolist2.png)\n\n![Filament Audit Resource](https://raw.githubusercontent.com/TappNetwork/filament-auditing/4.x/art/infolist3.png)\n\nRestore Action\n\n![Filament Audit Resource](https://raw.githubusercontent.com/TappNetwork/filament-auditing/4.x/art/restore_action.png)\n\n\n### Extending Columns\n\nIn case you need to add a column to the AuditsRelationManager that does\nnot already exist in the table, you can add it in the config using the format denoted in the example below, and it will be\nprepended to the table builder. The name of the column to be added is the key of an associative array that contains other information about the class, as shown in the example below. The class instance of the column must be added, but the methods can be left out if not required, or added wherever necessary. \n\n```php\n\u003c?php\n\nreturn [\n\n    'audits_extend' =\u003e [\n       'url' =\u003e [\n           'class' =\u003e \\Filament\\Tables\\Columns\\TextColumn::class, // required\n           'methods' =\u003e [\n               'sortable',\n               'default' =\u003e 'NIL',\n            ],\n        ],\n    ]\n\n];\n```\n\nAfter adding this information in the config, please run this command for changes to take place.\n\n```bash\nphp artisan optimize\n```\n\nMethods with two or more parameters can be specified with an array like so:\n\n```php\n\u003c?php\n\nreturn [\n\n    'audits_extend' =\u003e [\n       'created_at' =\u003e [\n           'class' =\u003e \\Filament\\Tables\\Columns\\TextColumn::class, // required\n           'methods' =\u003e [\n               'sortable',\n               'date' =\u003e ['Y-m-d H:i:s', 'America/New_York'],\n            ],\n        ],\n    ]\n\n];\n```\n\n### Custom View Data Formatting\n\nIf you want to modify the content of the audit to display the old and new values in a specific way, such as showing the value of a specific column instead of the ID for relationships, or even customize the entire view to display data in a different way than the default table, you can use one of these methods described below (first, make sure the plugin views are published):\n\n#### Show a related column instead of foreign id\n\nTo use another field to be displayed for relationships instead of the foreign id, in old and new values, you can add on the `mapping` array, in `filament-auditing.php` config file, the label and field that should be displayed, as well as the related model, using the foreign key as the array key. For example, on an `user` relationship with the `user_id` foreing key, this config will display the user `name` along with the `User` label:\n\n```bash\n'mapping' =\u003e [\n        'user_id' =\u003e [\n            'model' =\u003e App\\Models\\User::class,\n            'field' =\u003e 'name',\n            'label' =\u003e 'User',\n        ],\n    ],\n```\n\nAnd you'd like to customize the view, you can do it in the published view `views/vendor/filament-auditing/tables/columns/key-value.blade.php` file.\n\n#### Customizing the Old and New Values\n\nIf you need to customize the presentation for other old and new values, besides the related fields, you can add a `formatAuditFieldsForPresentation($field, $record)` method on the model that is auditable, with two parameters:\n- the first parameter contains the name of the field (`old_values` or `new_values`).\n- the second parameter contains de current audit record\n\nThis method must return the formatted audit fields.\n\nFor example, let's say you have an `Article` model that is auditable and contains a related user, and you added a `formatAuditFieldsForPresentation($field, $record)` method that returns the related user name instead of the id, and the data formatted with some HTML code:\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse OwenIt\\Auditing\\Contracts\\Audit;\nuse OwenIt\\Auditing\\Contracts\\Auditable;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Support\\Arr;\nuse Illuminate\\Support\\HtmlString;\n\nclass Article extends Model implements Auditable\n{\n    use \\OwenIt\\Auditing\\Auditable;\n\n    // ...\n\n    public function formatAuditFieldsForPresentation($field, Audit $record)\n    {\n        $fields = Arr::wrap($record-\u003e{$field});\n\n        $formattedResult = '\u003cul\u003e';\n\n        foreach ($fields as $key =\u003e $value) {\n            $formattedResult .= '\u003cli\u003e';\n            $formattedResult .= match ($key) {\n                'user_id' =\u003e '\u003cstrong\u003eUser\u003c/strong\u003e: '.User::find($record-\u003e{$field}['user_id'])?-\u003ename.'\u003cbr /\u003e',\n                'title' =\u003e '\u003cstrong\u003eTitle\u003c/strong\u003e: '.(string) str($record-\u003e{$field}['title'])-\u003etitle().'\u003cbr /\u003e',\n                'order' =\u003e '\u003cstrong\u003eOrder\u003c/strong\u003e: '.$record-\u003e{$field}['order'].'\u003cbr /\u003e',\n                'content' =\u003e '\u003cstrong\u003eContent\u003c/strong\u003e: '.$record-\u003e{$field}['content'].'\u003cbr /\u003e',\n                default =\u003e ' - ',\n            };\n            $formattedResult .= '\u003c/li\u003e';\n        }\n\n        $formattedResult .= '\u003c/ul\u003e';\n\n        return new HtmlString($formattedResult);\n    }\n\n    public function user(): BelongsTo\n    {\n        return $this-\u003ebelongsTo(User::class);\n    }\n}\n```\n\n#### Customizing the Entire View Content\n\nIf you'd like to customize the entire view content, you may set the `custom_audits_view` config value to `true` on `config/filament-auditing.php` file:\n\n```php\n'custom_audits_view' =\u003e true,\n```\n\nThis modification will allow you to take full control of the display and tailor it to your specific requirements. You can now add your custom content on `resources/views/vendor/filament-auditing/tables/custom-audit-content.blade.php` file. \nFor example:\n\n```php\n@php\n$type = (string) str(class_basename($owner))-\u003elower();\n@endphp\n\n@if(isset($records))\n    \u003cx-filament-tables::table\u003e\n        \u003cx-slot name=\"header\"\u003e\n            @foreach($headers as $header)\n            \u003cx-filament-tables::header-cell\u003e\n                {{$header}}\n            \u003c/x-filament-tables::header-cell\u003e\n            @endforeach\n        \u003c/x-slot\u003e\n        @foreach($records as $audit)\n            \u003cx-filament-tables::row\u003e\n                @foreach ($audit-\u003egetModified() as $attribute =\u003e $modified)\n                    \u003cx-filament-tables::cell\u003e\n                        @lang($type.'.metadata', $audit-\u003egetMetadata())\n                        \u003cbr /\u003e\n                        @php\n                            $current = $type.'.'.$audit-\u003eevent.'.modified.'.$attribute;\n\n                            $modified['new'] = $owner-\u003eformatFieldForPresentation($attribute, $modified['new']);\n\n                            if (isset($modified['old'])) {\n                                $modified['old'] = $owner-\u003eformatFieldForPresentation($attribute, $modified['old']);\n                            }\n                        @endphp\n\n                        @lang($current, $modified)\n                    \u003c/x-filament-tables::cell\u003e\n                @endforeach\n            \u003c/x-filament-tables::row\u003e\n        @endforeach\n    \u003c/x-filament-tables::table\u003e\n@else\n    \u003cdiv class=\"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400\"\u003e\n        @lang($type.'.unavailable_audits')\n    \u003c/div\u003e\n@endif\n```\n\nThe owner record is available to this view via `$owner` variable. To pass some additional parameters to the view, you may use the `custom_view_parameters` config:\n\n```php\n'custom_view_parameters' =\u003e [\n    'headers' =\u003e [\n        'Audit',\n    ],\n],\n```\n\nTo format a field, you may also add a `formatFieldForPresentation` method on the owner model, with the field name and value as parameters, like in the example above. This method must return a formatted field.\n\nFor example, in an `Article` model, to return the name of the related user:\n\n```php\npublic function formatFieldForPresentation($field, $value)\n{\n    return match($field) {\n        'user_id' =\u003e $value ? optional(User::find($value))-\u003ename : $value,\n        default =\u003e $value,\n    };\n}\n```\n\nAn example of the `article.php` lang file content used in the `custom-audit-content.blade.php` view code above:\n\n```php\n\u003c?php\n\nreturn [\n    'unavailable_audits' =\u003e 'No article audits available',\n\n    'metadata' =\u003e 'On :audit_created_at, :user_name [:audit_ip_address] :audit_event this record via :audit_url',\n\n    'updated' =\u003e [\n        'modified' =\u003e [\n            'order' =\u003e 'The Order has been modified from \u003cstrong\u003e:old\u003c/strong\u003e to \u003cstrong\u003e:new\u003c/strong\u003e',\n            'title' =\u003e 'The Title has been modified from \u003cstrong\u003e:old\u003c/strong\u003e to \u003cstrong\u003e:new\u003c/strong\u003e',\n            'content' =\u003e 'The Content has been modified from \u003cstrong\u003e:old\u003c/strong\u003e to \u003cstrong\u003e:new\u003c/strong\u003e',\n            'user_id' =\u003e 'The User has been modified from \u003cstrong\u003e:old\u003c/strong\u003e to \u003cstrong\u003e:new\u003c/strong\u003e',\n        ],\n    ],\n];\n```\n\n### Permissions\n\nTwo permissions are registered by default, allowing access to:\n\n- `audit`: view audits\n- `restoreAudit`: restore audits\n\nYou can override these permissions by adding a policy with `audit` and `restoreAudit`.\n\n### Event emitted\n\nThe `auditRestored` event is emitted when an audit is restored, so you could register a listener using the $listeners property to execute some extra code after the audit is restored.\n\nE.g.: on Edit page of your resource:\n\n```php\nprotected $listeners = [\n    'auditRestored',\n];\n\npublic function auditRestored()\n{\n    // your code\n}\n```\n\n### Event listener\n\nThe audits relation manager listen to the `updateAuditsRelationManager` event to refresh the audits table.\n\nSo you can dispatch this event in the Edit page of your resource (e.g.: in a edit page of a `PostResource` -\u003e `app/Filament/Resources/PostResource/Pages/EditPost.php`) when the form is updated:\n\n```php\nprotected function afterSave(): void\n{\n    $this-\u003edispatch('updateAuditsRelationManager');\n}\n```\n\n\u003e [!WARNING]\n\u003e When dispaching this event, set the [is_lazy](https://filamentphp.com/docs/3.x/panels/resources/relation-managers#disabling-lazy-loading) configuration to `false`, on `filament-auditing.php` \n\u003e config file, to avoid this exception: \"Typed property Filament\\Resources\\RelationManagers\\RelationManager::$table\n\u003e must not be accessed before initialization\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTappNetwork%2Ffilament-auditing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTappNetwork%2Ffilament-auditing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTappNetwork%2Ffilament-auditing/lists"}