update email template
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -12,7 +13,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ServiceRenewalReminderMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(
|
||||
public readonly Customer $customer,
|
||||
@@ -21,26 +22,38 @@ class ServiceRenewalReminderMail extends Mailable
|
||||
|
||||
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}");
|
||||
return new Envelope(
|
||||
subject: $this->renderFromTemplate('service_renewal_reminder', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
],
|
||||
htmlString: $this->renderFromTemplate('service_renewal_reminder', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
$serverName = $this->service->server_name ?? '';
|
||||
$price = $this->service->orderItem?->price
|
||||
? number_format((float) $this->service->orderItem->price, 0, ',', '.')
|
||||
: null;
|
||||
|
||||
return [
|
||||
'client_name' => $this->customer->fullname ?? '',
|
||||
'product_name' => $this->service->product?->name ?? 'Dịch vụ',
|
||||
'server_name_suffix' => $serverName ? " ({$serverName})" : '',
|
||||
'expires_at' => $this->service->expires_at
|
||||
? \Carbon\Carbon::parse($this->service->expires_at)->format('d/m/Y')
|
||||
: 'N/A',
|
||||
'price_row' => $price
|
||||
? '<tr><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;">Số tiền gia hạn:</td><td style="padding: 7px 11px; border-right: 1px solid #e8e8e8;"><strong>' . $price . ' VNĐ</strong></td></tr>'
|
||||
: '',
|
||||
'login_url' => rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap',
|
||||
'support_email' => 'support@tgs.com.vn',
|
||||
'support_phone' => '(028) 7309. 7379',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user