input('year'); $reports = Report::query() ->published() ->when($year, fn ($query, $year) => $query->where('year', $year)) ->ordered() ->get(); $years = Report::query() ->published() ->select('year') ->distinct() ->orderBy('year', 'desc') ->pluck('year'); return Inertia::render('report', [ 'reports' => ReportResource::collection($reports)->resolve(), 'filters' => [ 'year' => $year, ], 'years' => $years, ]); } public function download(Report $report) { if ($report->status !== 'publish') { abort(404); } if ($report->download_type === 'link') { if ($report->download_url) { return redirect()->away($report->download_url); } abort(404); } if (!$report->download_file) { abort(404); } $filePath = public_path('uploads/' . $report->download_file); if (!file_exists($filePath)) { abort(404); } return response()->download($filePath); } }