staging -> archivio locale -> tag legacy.'; public function handle(): int { $adminId = (int) $this->argument('amministratore_id'); $mdb = (string) $this->option('mdb'); $table = (string) $this->option('table'); $dryRun = (bool) $this->option('dry-run'); $skipTags = (bool) $this->option('skip-tags'); $truncateStaging = (bool) $this->option('truncate-staging'); $previewLimit = max(1, (int) ($this->option('preview-limit') ?: 10)); if ($adminId <= 0) { $this->error('amministratore_id non valido.'); return self::FAILURE; } $this->info('Sync fornitori legacy per amministratore #' . $adminId . ($dryRun ? ' [DRY-RUN]' : '')); $stageParams = [ 'tenant' => (string) $adminId, '--mdb' => $mdb, '--table' => $table, ]; if ($dryRun) { $stageParams['--preview'] = true; $stageParams['--limit'] = $previewLimit; } if ($truncateStaging && ! $dryRun) { $stageParams['--truncate'] = true; } $stageExit = Artisan::call('import:gescon-fornitori', $stageParams); $stageOutput = trim((string) Artisan::output()); $this->line('Step staging exit=' . $stageExit); if ($stageOutput !== '') { $this->line($stageOutput); } if ($stageExit !== 0) { return self::FAILURE; } $importParams = [ 'amministratore_id' => (string) $adminId, '--mdb' => $mdb, '--table' => $table, ]; if ($dryRun) { $importParams['--dry-run'] = true; } $importExit = Artisan::call('gescon:import-fornitori-legacy', $importParams); $importOutput = trim((string) Artisan::output()); $this->line('Step archivio locale exit=' . $importExit); if ($importOutput !== '') { $this->line($importOutput); } if ($importExit !== 0) { return self::FAILURE; } if (! $skipTags) { $tagParams = []; if ($dryRun) { $tagParams['--dry-run'] = true; } $tagExit = Artisan::call('fornitori:import-legacy-tags', $tagParams); $tagOutput = trim((string) Artisan::output()); $this->line('Step tag legacy exit=' . $tagExit); if ($tagOutput !== '') { $this->line($tagOutput); } if ($tagExit !== 0) { return self::FAILURE; } } $this->info($dryRun ? 'Dry-run sync fornitori legacy completato.' : 'Sync fornitori legacy completato.'); return self::SUCCESS; } }