diff --git a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php index 111d6df7..514c32cd 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php @@ -3,6 +3,7 @@ namespace App\Classes\Modules\Bookings\ControllersLogic; +use Illuminate\Support\Facades\File; use ZipArchive; use Carbon\Carbon; use App\Models\User; @@ -19,7 +20,7 @@ class DownloadBookingDocumentLogic /** * @param Request $request - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * @return void * @throws MalformedRequestException */ public function execute(Request $request) @@ -44,10 +45,23 @@ class DownloadBookingDocumentLogic } $zip->close(); + while (ob_get_level()) { + ob_end_clean(); + } + ob_start(); + header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK'); + header("Content-Type: application/zip"); + header("Content-Transfer-Encoding: Binary"); + header("Content-Length: " . filesize($attachment)); + header('Pragma: no-cache'); + header("Content-Disposition: attachment; filename=\"" . basename($attachment) . "\""); + ob_flush(); + ob_clean(); - $headers = array('Content-Type'=>'application/octet-stream',); - $zip_new_name = $request->input('type').".zip"; - return response()->download($attachment,$zip_new_name,$headers)->deleteFileAfterSend(true); + readfile($attachment); + File::delete($attachment); + + exit; // header('Content-Type: application/zip'); // header('Content-Length: ' . filesize($attachment)); diff --git a/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php b/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php index 90033356..95427363 100644 --- a/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php +++ b/app/Http/Controllers/Bookings/DownloadBookingDocumentController.php @@ -11,7 +11,7 @@ class DownloadBookingDocumentController /** * @param Request $request * @param DownloadBookingDocumentLogic $logic - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * @return void * @throws \App\Classes\Exceptions\MalformedRequestException */ public function download(Request $request, DownloadBookingDocumentLogic $logic) {