option('dry-run'); $limit = (int) $this->option('limit'); $now = now()->utc(); $result = $this->publicationService->publishDueScheduled($limit, $now); $candidates = $result['candidates']; if ($candidates->isEmpty()) { $this->line('No scheduled artworks due for publishing.'); return self::SUCCESS; } $this->info("Found {$candidates->count()} artwork(s) to publish." . ($dryRun ? ' [DRY RUN]' : '')); $published = 0; $errors = 0; foreach ($candidates as $candidate) { if ($dryRun) { $this->line(" [dry-run] Would publish artwork #{$candidate->id}: \"{$candidate->title}\""); continue; } try { $artwork = $this->publicationService->publishIfDue($candidate, $now); if ($artwork->artwork_status === 'published') { $published++; $this->line(" Published artwork #{$artwork->id}: \"{$artwork->title}\""); } } catch (\Throwable $e) { $errors++; Log::error("PublishScheduledArtworksCommand: failed to publish artwork #{$candidate->id}: {$e->getMessage()}"); $this->error(" Failed to publish #{$candidate->id}: {$e->getMessage()}"); } } if (! $dryRun) { $this->info("Done. Published: {$published}, Errors: {$errors}."); } return $errors > 0 ? self::FAILURE : self::SUCCESS; } }