PlatformAuditLog Model
The PlatformAuditLog model records all cross-tenant actions performed by platform managers.
Table: platform_audit_logs
Model: App\Models\PlatformAuditLog
Database Schema
| Column | Type | Nullable | Description |
|---|---|---|---|
id | bigint unsigned | No | Primary key |
platform_manager_user_id | bigint unsigned | No | Acting user. Foreign key to users, ON DELETE CASCADE |
target_organization_id | bigint unsigned | Yes | Target organization. Foreign key to organizations, ON DELETE SET NULL |
action | varchar(100) | No | Action name |
target_entity_type | varchar(100) | Yes | Model affected |
target_entity_id | bigint unsigned | Yes | Record ID |
before_state | json | Yes | Values before change |
after_state | json | Yes | Values after change |
reason | varchar(500) | Yes | Reason for action |
ip_address | varchar(45) | Yes | Request IP |
user_agent | varchar(500) | Yes | Request user agent |
created_at | timestamp | Yes | |
updated_at | timestamp | Yes |
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_stateandafter_statestore snapshots of the affected record.- Rows whose
created_atis older thanRETENTION_PLATFORM_AUDIT_LOGS_DAYS(default 365) are pruned daily bymodel:prune(PrunesByRetention).
Related Documentation
- Platform Management
- User Model (
App\Models\User)