diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index ef756cdbae2f..1c06a5d29917 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -821,7 +821,14 @@ class InvoiceController extends BaseController $contact = $invitation->contact; $invoice = $invitation->invoice; - $file = $invoice->service()->getInvoicePdf($contact); + // $file = $invoice->service()->getInvoicePdf($contact); + + /************** */ +$file_name = $invoice->numberFormatter().'.pdf'; + +$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle(); + + /************* */ $headers = ['Content-Type' => 'application/pdf']; @@ -830,8 +837,8 @@ class InvoiceController extends BaseController } return response()->streamDownload(function () use ($file) { - echo Storage::get($file); - }, basename($file), $headers); + echo $file; + }, $file_name, $headers); } /** diff --git a/app/Services/Recurring/GetInvoicePdf.php b/app/Services/Recurring/GetInvoicePdf.php index 448663f8e0cc..079bd55eea6e 100644 --- a/app/Services/Recurring/GetInvoicePdf.php +++ b/app/Services/Recurring/GetInvoicePdf.php @@ -20,6 +20,8 @@ class GetInvoicePdf extends AbstractService { public $entity; + public $contact; + public function __construct($entity, ClientContact $contact = null) { $this->entity = $entity;