From be6ebdfde83f34480a7ca304aa2c0f79bac39d2e Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 2 Mar 2022 03:50:47 +0800 Subject: [PATCH] download billing documents --- .../DownloadBookingDocumentLogic.php | 12 ++++++++++-- .../Bookings/DownloadBookingDocumentController.php | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php index 1aa0c06f..b7633d8a 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php @@ -23,7 +23,7 @@ class DownloadBookingDocumentLogic /** * @param Request $request - * @return bool + * @return void * @throws MalformedRequestException */ public function execute(Request $request) @@ -48,7 +48,15 @@ class DownloadBookingDocumentLogic } $zip->close(); - return Storage::disk('documents')->download('collections/' . $zip_file); + + header('Content-Type: application/zip'); + header('Content-Disposition: attachment; filename="'.basename($attachment).'"'); + header('Content-Length: ' . filesize($attachment)); + + flush(); + readfile($attachment); + // delete file + unlink($attachment); } } diff --git a/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php b/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php index c9c4f41a..d2a7d85c 100644 --- a/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php +++ b/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php @@ -11,11 +11,11 @@ class DownloadBookingDocumentController /** * @param Request $request * @param DownloadBookingDocumentLogic $logic - * @return bool + * @return void * @throws \App\Classes\Exceptions\MalformedRequestException */ public function download(Request $request, DownloadBookingDocumentLogic $logic) { - return $logic->execute($request); + $logic->execute($request); } } \ No newline at end of file