Implement superadmin audit log for mutations
This commit is contained in:
25
app/Filament/Resources/Pages/AuditedEditRecord.php
Normal file
25
app/Filament/Resources/Pages/AuditedEditRecord.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Pages;
|
||||
|
||||
use App\Services\Audit\SuperAdminAuditLogger;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class AuditedEditRecord extends EditRecord
|
||||
{
|
||||
protected function afterSave(): void
|
||||
{
|
||||
$changed = array_keys($this->record->getChanges());
|
||||
|
||||
if ($changed === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
app(SuperAdminAuditLogger::class)->recordModelMutation(
|
||||
'updated',
|
||||
$this->record,
|
||||
SuperAdminAuditLogger::fieldsMetadata($changed ?: $this->form->getState()),
|
||||
static::class
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user