1. Go to this page and download the library: Download tapp/filament-auditing 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/ */
tapp / filament-auditing example snippets
use Tapp\FilamentAuditing\Filament\Resources\Audits\AuditResource;
return [
'audits_sort' => [
'column' => 'created_at',
'direction' => 'desc',
],
'is_lazy' => true,
'grouped_table_actions' => false,
/**
* Extending Columns
* --------------------------------------------------------------------------
* In case you need to add a column to the AuditsRelationManager that does
* not already exist in the table, you can add it here, and it will be
* prepended to the table builder.
*/
'audits_extend' => [
// 'url' => [
// 'class' => \Filament\Tables\Columns\TextColumn::class,
// 'methods' => [
// 'sortable',
// 'searchable' => true,
// 'default' => 'N/A'
// ]
// ],
],
'custom_audits_view' => false,
'custom_view_parameters' => [
],
'mapping' => [
],
'resources' => [
'AuditResource' => AuditResource::class,
],
];
'tenancy' => [
// Enable tenancy support
'enabled' => true,
// The Tenant model class (e.g., App\Models\Team::class, App\Models\Organization::class)
'model' => \App\Models\Team::class,
// The tenant relationship name (defaults to snake_case of tenant model class name)
// For example: Team::class -> 'team', Organization::class -> 'organization'
// This should match what you configure in your Filament Panel:
// ->tenantOwnershipRelationshipName('team')
'relationship_name' => 'teams',
// The tenant column name (defaults to snake_case of tenant model class name + '_id')
// You can override this if needed
'column' => 'team_id',
],
use Tapp\FilamentAuditing\RelationManagers\AuditsRelationManager;
public static function getRelations(): array
{
return [
// ...
AuditsRelationManager::class,
];
}
use Tapp\FilamentAuditing\FilamentAuditingPlugin;
return $panel
->plugins([
FilamentAuditingPlugin::make(),
]);
public function formatFieldForPresentation($field, $value)
{
return match($field) {
'user_id' => $value ? optional(User::find($value))->name : $value,
default => $value,
};
}
return [
'unavailable_audits' => 'No article audits available',
'metadata' => 'On :audit_created_at, :user_name [:audit_ip_address] :audit_event this record via :audit_url',
'updated' => [
'modified' => [
'order' => 'The Order has been modified from <strong>:old</strong> to <strong>:new</strong>',
'title' => 'The Title has been modified from <strong>:old</strong> to <strong>:new</strong>',
'content' => 'The Content has been modified from <strong>:old</strong> to <strong>:new</strong>',
'user_id' => 'The User has been modified from <strong>:old</strong> to <strong>:new</strong>',
],
],
];
protected $listeners = [
'auditRestored',
];
public function auditRestored()
{
// your code
}
protected function afterSave(): void
{
$this->dispatch('updateAuditsRelationManager');
}