Skip to main content

PlatformAuditLog Model

The PlatformAuditLog model records all cross-tenant actions performed by platform managers.

Table: platform_audit_logs
Model: App\Models\PlatformAuditLog

Database Schema​

ColumnTypeNullableDescription
idbigint unsignedNoPrimary key
platform_manager_user_idbigint unsignedNoActing user. Foreign key to users, ON DELETE CASCADE
target_organization_idbigint unsignedYesTarget organization. Foreign key to organizations, ON DELETE SET NULL
actionvarchar(100)NoAction name
target_entity_typevarchar(100)YesModel affected
target_entity_idbigint unsignedYesRecord ID
before_statejsonYesValues before change
after_statejsonYesValues after change
reasonvarchar(500)YesReason for action
ip_addressvarchar(45)YesRequest IP
user_agentvarchar(500)YesRequest user agent
created_attimestampYes
updated_attimestampYes

Indexes: idx_pal_action (action), idx_pal_created_at (created_at), idx_pal_manager_user (platform_manager_user_id), idx_pal_target_entity (target_entity_type, target_entity_id), idx_pal_target_org (target_organization_id).

Relationships​

$log->platformManager() → User
$log->targetOrganization() → Organization

Usage Notes​

  • Platform audit logs are not tenant-scoped.
  • They are used for compliance, debugging, and security auditing.
  • before_state and after_state store snapshots of the affected record.
  • Rows whose created_at is older than RETENTION_PLATFORM_AUDIT_LOGS_DAYS (default 365) are pruned daily by model:prune (PrunesByRetention).