Change storeInvoicePdfAndGetPath method to storeDocumentPdfAndGetPath to make it compatible with other apps like Estimates, Credit/Debit Notes, Sales&Purchase Orders etc.

This commit is contained in:
Burak Çakırel 2021-04-30 14:57:44 +03:00
parent cc77fa780b
commit c66f0ac8be
No known key found for this signature in database
GPG Key ID: 48FFBB7771B99C7C
3 changed files with 6 additions and 6 deletions

View File

@ -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',
]);
}

View File

@ -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',
]);
}

View File

@ -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);