'mysql_presseecho', 'businessportal24' => 'mysql_businessportal', ]; public function handle(LegacyApiKeyImporter $importer): int { $portalOption = (string) $this->option('portal'); $dryRun = (bool) $this->option('dry-run'); $portals = $portalOption === 'all' ? array_keys(self::CONNECTIONS) : [$portalOption]; if (array_diff($portals, array_keys(self::CONNECTIONS)) !== []) { $this->error('Ungültiges Portal. Erlaubt: presseecho, businessportal24, all.'); return self::FAILURE; } if ($dryRun) { $this->warn('[DRY-RUN] Kein tatsächlicher Schreibvorgang.'); } foreach ($portals as $portal) { $rows = DB::connection(self::CONNECTIONS[$portal]) ->table('sf_guard_user_profile') ->whereNotNull('api_key') ->where('api_key', '!=', '') ->get(['user_id', 'api_key']) ->map(fn (object $row): array => [ 'legacy_id' => (int) $row->user_id, 'api_key' => (string) $row->api_key, ]); $result = $importer->import($portal, $rows, $dryRun); $this->table( ['Portal', 'Keys in Legacy-DB', 'Importiert', 'Schon vorhanden', 'Nicht berechtigt', 'Kein User-Mapping'], [[ $portal, $rows->count(), $result['imported'], $result['already_present'], $result['ineligible'], $result['unknown_user'], ]], ); foreach ($result['ineligible_users'] as $email) { $this->warn("Nicht berechtigt (kein aktiver Zahlungsstatus): {$email}"); } } return self::SUCCESS; } }