diff --git a/app/Notifications/Portal/PaymentReceived.php b/app/Notifications/Portal/PaymentReceived.php index 084b1acd7..3f2f8afb7 100644 --- a/app/Notifications/Portal/PaymentReceived.php +++ b/app/Notifications/Portal/PaymentReceived.php @@ -69,7 +69,7 @@ class PaymentReceived extends Notification // Attach the PDF file if ($this->attach_pdf) { - $message->attach($this->storeInvoicePdfAndGetPath($this->invoice), [ + $message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [ 'mime' => 'application/pdf', ]); } diff --git a/app/Notifications/Sale/Invoice.php b/app/Notifications/Sale/Invoice.php index c297c1a10..48e510c9c 100644 --- a/app/Notifications/Sale/Invoice.php +++ b/app/Notifications/Sale/Invoice.php @@ -60,7 +60,7 @@ class Invoice extends Notification // Attach the PDF file if ($this->attach_pdf) { - $message->attach($this->storeInvoicePdfAndGetPath($this->invoice), [ + $message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [ 'mime' => 'application/pdf', ]); } diff --git a/app/Traits/Documents.php b/app/Traits/Documents.php index aabd4e17a..3ad78ca60 100644 --- a/app/Traits/Documents.php +++ b/app/Traits/Documents.php @@ -124,17 +124,17 @@ trait Documents return $key; } - public function storeInvoicePdfAndGetPath($invoice) + public function storeDocumentPdfAndGetPath($document) { - event(new \App\Events\Document\DocumentPrinting($invoice)); + event(new \App\Events\Document\DocumentPrinting($document)); - $view = view($invoice->template_path, ['invoice' => $invoice])->render(); + $view = view($document->template_path, ['invoice' => $document, 'document' => $document])->render(); $html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8'); $pdf = app('dompdf.wrapper'); $pdf->loadHTML($html); - $file_name = $this->getDocumentFileName($invoice); + $file_name = $this->getDocumentFileName($document); $pdf_path = storage_path('app/temp/' . $file_name);