option('dry-run'); $ended = 0; // Narrowed in the query for the sake of the database, decided by // hasEnded() for the sake of the rule: the query is an index, not a // second opinion. $due = Instance::query() ->with(['host', 'dnsRecords']) ->where('status', 'cancellation_scheduled') ->whereNotNull('service_ends_at') ->where('service_ends_at', '<=', now()) ->cursor(); foreach ($due as $instance) { if (! $end->hasEnded($instance)) { continue; } $this->line(($dryRun ? '[dry-run] ' : '') ."{$instance->subdomain}: Laufzeit endete am " .$instance->service_ends_at->local()->isoFormat('LLL')); if ($dryRun || $end($instance)) { $ended++; } } $this->info($dryRun ? "Probelauf: {$ended} Dienst(e) würden beendet. Nichts wurde geändert." : "{$ended} Dienst(e) beendet."); return self::SUCCESS; } }