$data */ public static function log(string $action, array $data = [], ?int $userId = null): void { $userId ??= auth()->id(); Log::info("audit: {$action}", [...$data, 'user_id' => $userId]); try { AuditLog::query()->create(['user_id' => $userId, 'action' => $action, 'data' => $data]); } catch (Throwable $e) { Log::warning('Audit-Eintrag konnte nicht gespeichert werden: '.$e->getMessage()); } } }