From b7d7640cdb1dd907a2bd0a9fa923b6e7d5937abf Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 27 Oct 2026 09:06:59 +0530 Subject: [PATCH] Added download button in upload daily report --- app/Filament/Pages/UploadDailyReport.php | 49 +++++++++++++++++++ .../pages/upload-daily-report.blade.php | 7 +++ 2 files changed, 56 insertions(+) diff --git a/app/Filament/Pages/UploadDailyReport.php b/app/Filament/Pages/UploadDailyReport.php index ccb1d900..a2098eed 100644 --- a/app/Filament/Pages/UploadDailyReport.php +++ b/app/Filament/Pages/UploadDailyReport.php @@ -145,6 +145,55 @@ class UploadDailyReport extends Page implements HasForms } } + public function downloadTaskPdf(){ + $fileName = $this->filters['file_name'] ?? null; + + if (!$fileName) { + Notification::make() + ->title('File Name Required') + ->body('Please enter a file name before removing the PDF.') + ->danger() + ->send(); + + return; + } + + $filePath = "task_updates/{$fileName}.pdf"; + + if (!Storage::disk('local')->exists($filePath)) { + Notification::make() + ->title('PDF Not Found') + ->body('The selected PDF does not exist.') + ->danger() + ->send(); + $this->form->fill(['file_name' => null]); + return; + } + + if (Storage::disk('local')->exists($filePath)) { + if($filePath){ + $fullPath = Storage::disk('local')->path($filePath); + + Notification::make() + ->title('PDF Downloaded Successfully') + ->body('The PDF was downloaded successfully.') + ->success() + ->send(); + + return response()->download($fullPath, "{$fileName}.pdf"); + + } + else{ + Notification::make() + ->title('PDF downloaded Failed') + ->body('Unable to download the PDF. Please try again...') + ->success() + ->send(); + return; + } + } + } + public static function canAccess(): bool { return Auth::check() && Auth::user()->can('view upload daily report page'); diff --git a/resources/views/filament/pages/upload-daily-report.blade.php b/resources/views/filament/pages/upload-daily-report.blade.php index 97b4bd22..9aba412e 100644 --- a/resources/views/filament/pages/upload-daily-report.blade.php +++ b/resources/views/filament/pages/upload-daily-report.blade.php @@ -16,5 +16,12 @@ > Remove Task PDF +