feat: Add IT Support catalog and related migrations, seeders, and email templates
- 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.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ServiceRenewalReminderMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public readonly Customer $customer,
|
||||
public readonly Service $service,
|
||||
) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$name = $this->service->server_name ?? $this->service->product?->name ?? 'dịch vụ';
|
||||
|
||||
return new Envelope(subject: "Nhắc gia hạn dịch vụ {$name}");
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.customer.service-renewal-reminder',
|
||||
with: [
|
||||
'clientName' => $this->customer->fullname ?? '',
|
||||
'productName' => $this->service->product?->name ?? 'Dịch vụ',
|
||||
'serverName' => $this->service->server_name ?? '',
|
||||
'expiresAt' => $this->service->expires_at
|
||||
? \Carbon\Carbon::parse($this->service->expires_at)->format('d/m/Y')
|
||||
: 'N/A',
|
||||
'price' => $this->service->orderItem?->price
|
||||
? number_format((float) $this->service->orderItem->price, 0, ',', '.')
|
||||
: null,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user