download billing documents

This commit is contained in:
omair saleh
2022-03-02 04:31:51 +08:00
parent abc449dd83
commit 70a2979d2d
2 changed files with 19 additions and 5 deletions
@@ -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));
@@ -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) {