From a3dae762d01e87581a06535251fa83b2b3dd5771 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 6 Mar 2022 20:41:43 +1100 Subject: [PATCH] Fixes for bulk download entities --- app/Jobs/Credit/ZipCredits.php | 5 +++-- app/Jobs/Invoice/ZipInvoices.php | 8 ++++++-- app/Jobs/Quote/ZipQuotes.php | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/Jobs/Credit/ZipCredits.php b/app/Jobs/Credit/ZipCredits.php index 81e6d8518c4b..afffeb9488cb 100644 --- a/app/Jobs/Credit/ZipCredits.php +++ b/app/Jobs/Credit/ZipCredits.php @@ -91,8 +91,9 @@ class ZipCredits implements ShouldQueue foreach ($this->credits as $credit) { - $download_file = file_get_contents($credit->pdf_file_path($invitation, 'url', true)); - $zipFile->addFromString(basename($credit->pdf_file_path($invitation)), $download_file); + $file = $credit->service()->getCreditPdf($credit->invitations()->first()); + $zip_file_name = basename($file); + $zipFile->addFromString($zip_file_name, Storage::get($file)); } diff --git a/app/Jobs/Invoice/ZipInvoices.php b/app/Jobs/Invoice/ZipInvoices.php index 50ebcdd4d63c..b9a4856a4d90 100644 --- a/app/Jobs/Invoice/ZipInvoices.php +++ b/app/Jobs/Invoice/ZipInvoices.php @@ -91,8 +91,12 @@ class ZipInvoices implements ShouldQueue foreach ($this->invoices as $invoice) { - $download_file = file_get_contents($invoice->pdf_file_path($invitation, 'url', true)); - $zipFile->addFromString(basename($invoice->pdf_file_path($invitation)), $download_file); + $file = $invoice->service()->getInvoicePdf(); + $zip_file_name = basename($file); + $zipFile->addFromString($zip_file_name, Storage::get($file)); + + //$download_file = file_get_contents($invoice->pdf_file_path($invitation, 'url', true)); + //$zipFile->addFromString(basename($invoice->pdf_file_path($invitation)), $download_file); } diff --git a/app/Jobs/Quote/ZipQuotes.php b/app/Jobs/Quote/ZipQuotes.php index 50bce4607ea9..6e00710b1c74 100644 --- a/app/Jobs/Quote/ZipQuotes.php +++ b/app/Jobs/Quote/ZipQuotes.php @@ -92,8 +92,12 @@ class ZipQuotes implements ShouldQueue foreach ($this->quotes as $quote) { - $download_file = file_get_contents($quote->pdf_file_path($invitation, 'url', true)); - $zipFile->addFromString(basename($quote->pdf_file_path($invitation)), $download_file); + $file = $quote->service()->getQuotePdf(); + $zip_file_name = basename($file); + $zipFile->addFromString($zip_file_name, Storage::get($file)); + + // $download_file = file_get_contents($quote->pdf_file_path($invitation, 'url', true)); + // $zipFile->addFromString(basename($quote->pdf_file_path($invitation)), $download_file); }