download billing documents

This commit is contained in:
omair saleh
2022-03-02 03:58:27 +08:00
parent c98b13efa4
commit da6ea1e1c5
@@ -47,15 +47,20 @@ class DownloadBookingDocumentLogic
$zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
}
$zip->close();
if ($zip->close() === false) {
exit("Error creating ZIP file");
};
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($attachment));
if (file_exists($attachment)) {
// download zip
readfile($attachment);
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$attachment.'.zip');
header('Content-Length: ' . filesize($attachment));
readfile($attachment);
} else {
exit("Could not find Zip file to download");
}
// delete after download
unlink($attachment);
}