'whmcs:sync-clients', 'forceSync' => true], ['command' => 'whmcs:sync-products', 'forceSync' => false], ['command' => 'whmcs:sync-orders', 'forceSync' => true], ['command' => 'whmcs:sync-order-items', 'forceSync' => false], ['command' => 'whmcs:sync-invoices', 'forceSync' => true], ['command' => 'whmcs:sync-services', 'forceSync' => false], ['command' => 'whmcs:sync-domains', 'forceSync' => false], ]; public function handle(): int { if ($this->option('with-domain-sync')) { $exitCode = $this->runStep('domain:sync', []); if ($exitCode !== self::SUCCESS) { return $exitCode; } } else { $this->warn('Skipping domain:sync — whmcs:sync-domains expects it to already be up to date. Pass --with-domain-sync to run it here.'); } foreach (self::STEPS as $step) { $arguments = $step['forceSync'] ? ['--sync' => true] : []; $exitCode = $this->runStep($step['command'], $arguments); if ($exitCode !== self::SUCCESS) { return $exitCode; } } $this->info('whmcs:sync-all completed successfully.'); return self::SUCCESS; } private function runStep(string $command, array $arguments): int { $this->newLine(); $this->info("==> {$command}"); $exitCode = $this->call($command, $arguments); if ($exitCode !== self::SUCCESS) { $this->error("{$command} failed with exit code {$exitCode}; stopping."); } return $exitCode; } }