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 PKJ historical data capture for {$month}/{$year}..."); try { if ($useQueue) { // Dispatch to queue CapturePKJHistoricalDataJob::dispatch($month, $year); $this->info('✓ PKJ historical data capture job dispatched to queue'); $this->info('You can monitor the job in Horizon dashboard'); } else { // Run immediately $job = new CapturePKJHistoricalDataJob($month, $year); $job->handle(app(PKJHistoricalDataService::class)); $this->info('✓ PKJ historical data capture completed immediately'); } } catch (\Exception $e) { $this->error('Error: '.$e->getMessage()); return 1; } return 0; } }