use App\Abstracts\Notification;
use App\Models\Common\EmailTemplate;
class Invoice extends Notification
{
public $invoice;
public $template;
public $attach_pdf;
public function __construct($invoice = null, $template_alias = null, $attach_pdf = false)
{
parent::__construct();
$this->invoice = $invoice;
$this->template = EmailTemplate::alias($template_alias)->first();
$this->attach_pdf = $attach_pdf;
}
public function toMail($notifiable)
{
$message = $this->initMessage();
// Attach the PDF file
if ($this->attach_pdf) {
$message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
'mime' => 'application/pdf',
]);
}
return $message;
}
}