imageHashService = $imageHashService; } /** * Execute the console command. */ public function handle() { $force = $this->option('force'); $query = MemeMedia::query(); if (! $force) { $query->whereNull('image_hash'); } $records = $query->whereNotNull('webp_url')->get(); if ($records->isEmpty()) { $this->info('No records found to process.'); return; } $this->info("Processing {$records->count()} records..."); $progressBar = $this->output->createProgressBar($records->count()); $progressBar->start(); $processed = 0; $failed = 0; foreach ($records as $record) { $hash = $this->imageHashService->generateHashFromUrl($record->webp_url); if ($hash) { $record->update(['image_hash' => $hash]); $processed++; } else { $failed++; $this->newLine(); $this->error("Failed to generate hash for ID: {$record->id} - {$record->webp_url}"); } $progressBar->advance(); } $progressBar->finish(); $this->newLine(); $this->info('Processing complete!'); $this->info("Processed: {$processed}"); $this->info("Failed: {$failed}"); } }