diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 6478dd1ebfbc..871034337f9f 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -589,14 +589,20 @@ class CreditController extends BaseController public function downloadPdf($invitation_key) { $invitation = $this->credit_repository->getInvitationByKey($invitation_key); - // $contact = $invitation->contact; + $credit = $invitation->credit; $file = $credit->service()->getCreditPdf($invitation); + $headers = ['Content-Type' => 'application/pdf']; + + if(request()->input('inline') == 'true') + $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file), ['Content-Type' => 'application/pdf']); + }, basename($file), $headers); + } diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 1e831d4bae8c..dbbddde36c60 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -804,9 +804,15 @@ class InvoiceController extends BaseController $file = $invoice->service()->getInvoicePdf($contact); + $headers = ['Content-Type' => 'application/pdf']; + + if(request()->input('inline') == 'true') + $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file), ['Content-Type' => 'application/pdf']); + }, basename($file), $headers); + } /** diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index c47fa3f2178a..843818fabc23 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -740,11 +740,16 @@ class QuoteController extends BaseController $file = $quote->service()->getQuotePdf($contact); + $headers = ['Content-Type' => 'application/pdf']; + + if(request()->input('inline') == 'true') + $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file), ['Content-Type' => 'application/pdf']); + }, basename($file), $headers); + - // return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); } /**