- Created migration to add 'group_label' to 'product_type_fields' table. - Implemented ItSupportCatalogSeeder to populate IT Support features and tiers. - Added ProductCategorySeeder for initial product categories. - Developed ProductMockupSeeder for mockup products in various categories. - Introduced ProductTypeFieldSeeder to define fields for different product types. - Created email templates for VPS service information and service renewal reminders.
72 lines
2.5 KiB
PHP
72 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Attachment;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* Gửi thông tin VPS bằng template tĩnh send-info-vps.blade.php
|
|
* (không phụ thuộc EmailNotificationTemplate/Template trong DB).
|
|
*
|
|
* KHÔNG implement ShouldQueue — mailable này được gọi từ bên trong
|
|
* SendInformationVirtualMachine (đã là queued job). Gửi đồng bộ để
|
|
* tránh Laravel cố JSON-encode $invoicePdf (binary PDF).
|
|
*/
|
|
class VmInfoMail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public function __construct(
|
|
public readonly array $data,
|
|
public readonly ?string $invoicePdf = null,
|
|
public readonly ?string $invoicePdfFileName = null,
|
|
) {}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
$osName = $this->data['os_name'] ?? '';
|
|
|
|
return new Envelope(
|
|
subject: "VPS của bạn đã sẵn sàng" . ($osName ? " — {$osName}" : ''),
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
view: 'emails.customer.send-info-vps',
|
|
with: [
|
|
'companyName' => $this->data['company_name'] ?? '',
|
|
'companyLogo' => $this->data['company_logo'] ?? '',
|
|
'clientName' => $this->data['client_name'] ?? '',
|
|
'productName' => $this->data['product_name'] ?? '',
|
|
'productBilling' => $this->data['product_billing'] ?? '',
|
|
'productPrice' => $this->data['product_price'] ?? '',
|
|
'serviceHost' => $this->data['service_host'] ?? '',
|
|
'serviceUsername' => $this->data['service_username'] ?? '',
|
|
'servicePort' => $this->data['service_port'] ?? '',
|
|
'servicePassword' => $this->data['service_password'] ?? '',
|
|
'osName' => $this->data['os_name'] ?? '',
|
|
'serviceDueExp' => $this->data['service_due_exp'] ?? '',
|
|
],
|
|
);
|
|
}
|
|
|
|
public function attachments(): array
|
|
{
|
|
if ($this->invoicePdf !== null && $this->invoicePdfFileName !== null) {
|
|
return [
|
|
Attachment::fromData(fn () => $this->invoicePdf, $this->invoicePdfFileName)
|
|
->withMime('application/pdf'),
|
|
];
|
|
}
|
|
|
|
return [];
|
|
}
|
|
}
|