subMonth(); $this->selectedPeriod = $previousMonth->format('Y-m'); } public function getAvailableMonthsProperty(): array { $months = []; for ($i = 1; $i <= 12; $i++) { $date = now()->subMonths($i); $months[] = [ 'value' => $date->format('Y-m'), 'label' => $date->translatedFormat('F Y'), ]; } return $months; } public function generate(): ?StreamedResponse { $this->generating = true; try { [$year, $month] = explode('-', $this->selectedPeriod); $service = app(MonthlyReportService::class); return $service->generate((int) $year, (int) $month); } catch (\Exception $e) { $this->dispatch('notify', type: 'error', message: __('report.report_failed')); return null; } finally { $this->generating = false; } } }; ?>