mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
* Create PHP CS Fixer config and add to CI workflow * Run php cs fixer on project * Add newline at end of file * Update to use PHP CS Fixer v3 * Run v3 config on project * Run seperate config in CI
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Crater\Mail;
|
|
|
|
use Crater\Models\EmailLog;
|
|
use Crater\Models\Payment;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class SendPaymentMail extends Mailable
|
|
{
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
public $data = [];
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* Build the message.
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function build()
|
|
{
|
|
EmailLog::create([
|
|
'from' => $this->data['from'],
|
|
'to' => $this->data['to'],
|
|
'subject' => $this->data['subject'],
|
|
'body' => $this->data['body'],
|
|
'mailable_type' => Payment::class,
|
|
'mailable_id' => $this->data['payment']['id'],
|
|
]);
|
|
|
|
$mailContent = $this->from($this->data['from'], config('mail.from.name'))
|
|
->subject($this->data['subject'])
|
|
->markdown('emails.send.payment', ['data', $this->data]);
|
|
|
|
if ($this->data['attach']['data']) {
|
|
$mailContent->attachData(
|
|
$this->data['attach']['data']->output(),
|
|
$this->data['payment']['payment_number'].'.pdf'
|
|
);
|
|
}
|
|
|
|
return $mailContent;
|
|
}
|
|
}
|