Files
coolify/app/Traits/AuditsApplicationSettings.php
T
Andras Bacsai 16a8c7999d feat(audit): log account, resource, and instance settings changes
Add audit events for account actions, server and application settings,
services, destinations, storage, backup schedules, and scheduled tasks.
Track changed fields and skip unchanged saves without logging file content.

Add regression coverage for audit events and changed-field detection.
2026-10-04 17:32:50 +02:00

32 lines
854 B
PHP

<?php
namespace App\Traits;
use App\Models\Application;
trait AuditsApplicationSettings
{
/**
* Save the application's settings and record `ui.application.settings_updated` with the
* names of the changed fields. Nothing is recorded when no setting changed.
*/
private function saveApplicationSettingsWithAudit(Application $application): void
{
$settings = $application->settings;
$changedFields = auditChangedFields($settings);
$settings->save();
if ($changedFields === []) {
return;
}
auditLog('ui.application.settings_updated', [
'team_id' => $application->team()?->id,
'application_uuid' => $application->uuid,
'application_name' => $application->name,
'changed_fields' => $changedFields,
]);
}
}