option('month'); $year = $this->option('year'); $useQueue = $this->option('queue'); // If no month/year provided, use previous month if (! $month || ! $year) { $lastMonth = Carbon::now()->subMonth(); $month = $month ?: $lastMonth->format('m'); $year = $year ?: $lastMonth->format('Y'); } $this->info("Triggering KJC historical data capture for {$month}/{$year}..."); try { if ($useQueue) { // Dispatch to queue CaptureKJCHistoricalDataJob::dispatch($month, $year); $this->info('✓ KJC historical data capture job dispatched to queue'); $this->info('You can monitor the job in Horizon dashboard'); } else { // Run immediately $job = new CaptureKJCHistoricalDataJob($month, $year); $job->handle(app(KJCHistoricalDataService::class)); $this->info('✓ KJC historical data capture completed immediately'); } } catch (\Exception $e) { $this->error('Error: '.$e->getMessage()); return 1; } return 0; } }