argument('unit'); $unit = Unit::where('name', $unitName)->first(); if (! $unit) { $this->error("Unit '{$unitName}' not found."); return 1; } $month = strtolower(now()->format('F')); $week = (int) ceil(now()->day / 7); if (! $this->option('force')) { $existingReports = KJCReport::where('unit_id', $unit->id) ->where('report_type', 'weekly') ->where('report_month', $month) ->where('report_week', $week) ->exists(); if ($existingReports) { $this->info("Reports for {$unitName} - {$month} week {$week} already exist. Skipping."); return 0; } } $user = User::where('unit_id', $unit->id)->first(); GenerateTeamWeeklyReports::dispatch($unit->id, $month, $week, $user?->id); $this->info("✓ Queued weekly report generation for {$unitName} - {$month} week {$week}"); return 0; } }