unless($this->option('all'), fn ($q) => $q->pending()) ->orderBy('id') ->limit(max(1, (int) $this->option('limit'))) ->get(); if ($media->isEmpty()) { $this->components->info('Nothing to process.'); return self::SUCCESS; } $failed = 0; foreach ($media as $item) { $processor->process($item->refresh()); if ($item->refresh()->error) { $failed++; $this->components->error("{$item->path} — {$item->error}"); continue; } $this->components->twoColumnDetail( $item->path, $item->width ? "{$item->width}×{$item->height} · ".count($item->variants ?? []).' versions' : 'no dimensions', ); } $this->newLine(); $this->components->info("Processed {$media->count()} images, {$failed} failed."); // A failure here is usually a missing file, which is worth a non-zero // exit in a deploy script. return $failed > 0 ? self::FAILURE : self::SUCCESS; } }