update
This commit is contained in:
@@ -3,15 +3,11 @@
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Enums\Invoice\InvoiceStatus;
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use App\Models\Invoice;
|
||||
use App\Services\InvoicePaymentService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
|
||||
/**
|
||||
* KHÔNG implement ShouldQueue — gọi từ trong queued job, gửi đồng bộ.
|
||||
@@ -20,10 +16,8 @@ use Illuminate\Mail\Mailables\Envelope;
|
||||
* đi qua bảng email_notification_templates riêng và rơi về blade khi không có template —
|
||||
* hai hệ template song song cho cùng một email, admin sửa một nơi thì nơi kia vẫn nguyên.
|
||||
*/
|
||||
class InvoiceNotificationMail extends Mailable
|
||||
class InvoiceNotificationMail extends TemplateMailable
|
||||
{
|
||||
use RequiresDbTemplate;
|
||||
|
||||
public function __construct(
|
||||
public readonly Invoice $invoice,
|
||||
public readonly Collection $invoiceAttachments,
|
||||
@@ -36,20 +30,6 @@ class InvoiceNotificationMail extends Mailable
|
||||
public readonly ?string $paymentUrl = null,
|
||||
) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: $this->renderFromTemplate('invoice_notification', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
htmlString: $this->renderFromTemplate('invoice_notification', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
public function attachments(): array
|
||||
{
|
||||
if ($this->invoicePdf !== null && $this->invoicePdfFileName !== null) {
|
||||
@@ -62,7 +42,12 @@ class InvoiceNotificationMail extends Mailable
|
||||
return [];
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
protected function scenario(): string
|
||||
{
|
||||
return 'invoice_notification';
|
||||
}
|
||||
|
||||
protected function variables(): array
|
||||
{
|
||||
$isRenewal = $this->type === 'renewal';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user