Skip to content

Commit

Permalink
Change storeInvoicePdfAndGetPath method to storeDocumentPdfAndGetPath…
Browse files Browse the repository at this point in the history
… to make it compatible with other apps like Estimates, Credit/Debit Notes, Sales&Purchase Orders etc.
  • Loading branch information
burakcakirel committed Apr 30, 2021
1 parent cc77fa7 commit c66f0ac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Notifications/Portal/PaymentReceived.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function toMail($notifiable)

// Attach the PDF file
if ($this->attach_pdf) {
$message->attach($this->storeInvoicePdfAndGetPath($this->invoice), [
$message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
'mime' => 'application/pdf',
]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/Sale/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function toMail($notifiable)

// Attach the PDF file
if ($this->attach_pdf) {
$message->attach($this->storeInvoicePdfAndGetPath($this->invoice), [
$message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
'mime' => 'application/pdf',
]);
}
Expand Down
8 changes: 4 additions & 4 deletions app/Traits/Documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ protected function getSettingKey($type, $setting_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');

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

Expand Down

0 comments on commit c66f0ac

Please sign in to comment.