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/ */
use Tapp\FilamentAuditing\RelationManagers\AuditsRelationManager;
public static function getRelations(): array
{
return [
// ...
AuditsRelationManager::class,
];
}
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');
}