mirror of
https://github.com/crater-invoice/crater.git
synced 2025-11-01 06:01:08 -04:00
feat(emails): implemented sending invoice, estimates and payments as attachements
This commit is contained in:
@ -13,17 +13,15 @@ class SendEstimateMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data = [];
|
||||
public $pdfData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data, $pdfData)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->pdfData = $pdfData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,22 +40,15 @@ class SendEstimateMail extends Mailable
|
||||
'mailable_id' => $this->data['estimate']['id']
|
||||
]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
$mailContent = $this->from($this->data['from'])
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.estimate', ['data', $this->data]);
|
||||
=======
|
||||
return $this->from($this->data['from'], config('mail.from.name'))
|
||||
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.estimate', ['data', $this->data]);
|
||||
>>>>>>> master
|
||||
|
||||
if ($this->pdfData) {
|
||||
if ($this->data['attach']['data'])
|
||||
$mailContent->attachData(
|
||||
$this->pdfData->output(),
|
||||
$this->data['attach']['data']->output(),
|
||||
$this->data['estimate']['estimate_number'] . '.pdf'
|
||||
);
|
||||
}
|
||||
|
||||
return $mailContent;
|
||||
}
|
||||
|
||||
@ -14,17 +14,15 @@ class SendInvoiceMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data = [];
|
||||
public $pdfData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data, $pdfData)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->pdfData = $pdfData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,23 +41,16 @@ class SendInvoiceMail extends Mailable
|
||||
'mailable_id' => $this->data['invoice']['id']
|
||||
]);
|
||||
|
||||
$mailContent = $this->from($this->data['from'])
|
||||
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.invoice', ['data', $this->data]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if ($this->pdfData) {
|
||||
if ($this->data['attach']['data'])
|
||||
$mailContent->attachData(
|
||||
$this->pdfData->output(),
|
||||
$this->data['attach']['data']->output(),
|
||||
$this->data['invoice']['invoice_number'] . '.pdf'
|
||||
);
|
||||
}
|
||||
|
||||
return $mailContent;
|
||||
=======
|
||||
return $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.invoice', ['data', $this->data]);
|
||||
>>>>>>> master
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,17 +14,15 @@ class SendPaymentMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $data = [];
|
||||
public $pdfData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data, $pdfData)
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->pdfData = $pdfData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,24 +41,16 @@ class SendPaymentMail extends Mailable
|
||||
'mailable_id' => $this->data['payment']['id']
|
||||
]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
$mailContent = $this->from($this->data['from'])
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.payment', ['data', $this->data]);
|
||||
|
||||
if ($this->pdfData) {
|
||||
$mailContent->attachData(
|
||||
$this->pdfData->output(),
|
||||
$this->data['payment']['payment_number'] . '.pdf'
|
||||
);
|
||||
}
|
||||
|
||||
return $mailContent;
|
||||
=======
|
||||
return $this->from($this->data['from'], config('mail.from.name'))
|
||||
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
||||
->subject($this->data['subject'])
|
||||
->markdown('emails.send.payment', ['data', $this->data]);
|
||||
|
||||
>>>>>>> master
|
||||
if ($this->data['attach']['data'])
|
||||
$mailContent->attachData(
|
||||
$this->data['attach']['data']->output(),
|
||||
$this->data['payment']['payment_number'] . '.pdf'
|
||||
);
|
||||
|
||||
return $mailContent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,9 +379,9 @@ class Estimate extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = $this->company->toArray();
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$pdfData = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data, $pdfData));
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data));
|
||||
|
||||
if ($this->status == Estimate::STATUS_DRAFT) {
|
||||
$this->status = Estimate::STATUS_SENT;
|
||||
|
||||
@ -429,7 +429,7 @@ class Invoice extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = Company::find($this->company_id);
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$pdfData = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
if ($this->status == Invoice::STATUS_DRAFT) {
|
||||
$this->status = Invoice::STATUS_SENT;
|
||||
@ -437,7 +437,7 @@ class Invoice extends Model implements HasMedia
|
||||
$this->save();
|
||||
}
|
||||
|
||||
\Mail::to($data['to'])->send(new SendInvoiceMail($data, $pdfData));
|
||||
\Mail::to($data['to'])->send(new SendInvoiceMail($data));
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
|
||||
@ -124,9 +124,9 @@ class Payment extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = Company::find($this->company_id);
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$pdfData = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendPaymentMail($data, $pdfData));
|
||||
\Mail::to($data['to'])->send(new SendPaymentMail($data));
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
|
||||
Reference in New Issue
Block a user