|null $counts */ public function record(string $id, string $status, bool $dryRun, bool $deactivateMissing, int $duration, ?array $counts = null, ?string $failure = null): void { try { DB::table('ad_sync_runs')->insert([ 'id' => $id, 'status' => $status, 'dry_run' => $dryRun, 'deactivate_missing' => $deactivateMissing, 'duration_ms' => $duration, 'counts' => $counts === null ? null : json_encode($counts, JSON_THROW_ON_ERROR), 'failure' => $failure, 'finished_at' => now(), ]); } catch (Throwable $exception) { Log::warning('Active Directory sync history could not be saved.', [ 'run_id' => $id, 'exception_type' => $exception::class, ]); } } }