Merge pull request #2013 from burakcakirel/document-pdf

Change storeInvoicePdfAndGetPath method to storeDocumentPdfAndGetPath…
This commit is contained in:
Cüneyt Şentürk 2021-05-01 11:18:19 +03:00 committed by GitHub
commit 261d18506f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -69,7 +69,7 @@ class PaymentReceived extends Notification
// Attach the PDF file // Attach the PDF file
if ($this->attach_pdf) { if ($this->attach_pdf) {
$message->attach($this->storeInvoicePdfAndGetPath($this->invoice), [ $message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
'mime' => 'application/pdf', 'mime' => 'application/pdf',
]); ]);
} }

View File

@ -60,7 +60,7 @@ class Invoice extends Notification
// Attach the PDF file // Attach the PDF file
if ($this->attach_pdf) { if ($this->attach_pdf) {
$message->attach($this->storeInvoicePdfAndGetPath($this->invoice), [ $message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
'mime' => 'application/pdf', 'mime' => 'application/pdf',
]); ]);
} }

View File

@ -124,17 +124,17 @@ trait Documents
return $key; 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'); $html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
$pdf = app('dompdf.wrapper'); $pdf = app('dompdf.wrapper');
$pdf->loadHTML($html); $pdf->loadHTML($html);
$file_name = $this->getDocumentFileName($invoice); $file_name = $this->getDocumentFileName($document);
$pdf_path = storage_path('app/temp/' . $file_name); $pdf_path = storage_path('app/temp/' . $file_name);