option('portal'); $classification = (string) $this->option('classification'); if (! in_array($portal, ['presseecho', 'businessportal24', 'both', 'all'], true)) { $this->error("Unbekanntes Portal: {$portal}"); return self::FAILURE; } if (! in_array($classification, ['eligible', 'needs_review', 'blocked', 'all'], true)) { $this->error("Unbekannte Klassifizierung: {$classification}"); return self::FAILURE; } $report = $reporter->report($portal); $customers = collect($report['customers']); if ($classification !== 'all') { $customers = $customers ->where('classification', $classification) ->values(); } $this->info('Legacy-API-Kundenreport'); $this->newLine(); $this->line("Portal: {$portal}"); $this->line("Kandidaten: {$report['summary']['total_candidates']}"); $this->line("Freigabefähig: {$report['summary']['eligible']}"); $this->line("Manuell prüfen: {$report['summary']['needs_review']}"); $this->line("Gesperrt: {$report['summary']['blocked']}"); if ($customers->isNotEmpty()) { $this->newLine(); $this->table( ['ID', 'E-Mail', 'Portal', 'Letzte Rechnung', 'Status', 'Klassifizierung'], $customers ->take(25) ->map(fn (array $customer): array => [ $customer['user_id'], $customer['email'], $customer['portal'], $customer['latest_legacy_invoice']['number'] ?? '-', $customer['latest_legacy_invoice']['status'] ?? '-', $customer['classification'], ]) ->all() ); } if (! (bool) $this->option('no-report')) { $path = 'migration/legacy-api-customers-'.now()->format('Ymd-His').'.json'; Storage::disk('local')->put($path, json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); $this->newLine(); $this->line("Report geschrieben: storage/app/private/{$path}"); } return self::SUCCESS; } }