From 5885ff16e559d319c0146b0364d85ec0c91e66ec Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 26 May 2024 19:45:37 +0800 Subject: [PATCH] Laravel Vapor - sync code for download files in bulk from S3 --- .../DownloadBookingDocumentLogic.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php index d32656a0..fde8c118 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php @@ -30,8 +30,20 @@ class DownloadBookingDocumentLogic { Auth::login(User::findOrFail(1)); $document_type = str_replace(' ', '', $request->input('type')); + + $zipDirectory = storage_path('/app/documents/collections'); + + if (!file_exists($zipDirectory)) { + mkdir($zipDirectory, 0755, true); + } + $zip_file = $document_type.'.zip'; + $attachment = storage_path().'/app/documents/collections/' . $zip_file; + Log::info('attachment 1: '. $attachment); + + $attachment = "{$zipDirectory}/{$zip_file}"; + Log::info('attachment 2: '. $attachment); $bookings = Booking::where('status', ApprovalStatus::COMPLETED) ->whereDate('created_at', '>=', Carbon::parse($request->input('startDate')))