whereIn('status', ['pending', 'failed']) ->whereNotNull('hosting_node_id') ->whereNull('provisioned_at') ->with(['user:id,name,email', 'product:id,name', 'node:id,name']) ->get(); if ($pendingAccounts->isEmpty()) { $this->info('No pending hosting accounts found.'); return self::SUCCESS; } $this->info("Found {$pendingAccounts->count()} pending account(s):"); $this->newLine(); foreach ($pendingAccounts as $account) { $this->line(" • [{$account->id}] {$account->username} - {$account->user?->name} ({$account->user?->email})"); $this->line(" Product: {$account->product?->name}, Node: {$account->node?->name}, Status: {$account->status}"); } $this->newLine(); if ($this->option('dry-run')) { $this->warn('Dry run mode - no jobs dispatched.'); return self::SUCCESS; } if (! $this->confirm('Dispatch provisioning jobs for these accounts?')) { $this->info('Aborted.'); return self::SUCCESS; } $dispatched = 0; foreach ($pendingAccounts as $account) { // Reset status to pending if it was failed if ($account->status === 'failed') { $account->update(['status' => 'pending', 'notes' => null]); } ProvisionHostingAccountJob::dispatch($account->id); $dispatched++; $this->info("Dispatched job for account #{$account->id} ({$account->username})"); } $this->newLine(); $this->info("Dispatched {$dispatched} provisioning job(s). Check queue worker for progress."); return self::SUCCESS; } }