48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\Service;
|
|
use App\Support\EmailTemplateShell;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class ServiceRenewalReminderMail extends TemplateMailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public function __construct(
|
|
public readonly Customer $customer,
|
|
public readonly Service $service,
|
|
) {}
|
|
|
|
protected function scenario(): string
|
|
{
|
|
return 'service_renewal_reminder';
|
|
}
|
|
|
|
protected function variables(): 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
|
|
? EmailTemplateShell::row('Số tiền gia hạn', $price . ' VNĐ')
|
|
: '',
|
|
'login_url' => rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap',
|
|
'support_email' => 'support@tgs.com.vn',
|
|
'support_phone' => '(028) 7309. 7379',
|
|
];
|
|
}
|
|
}
|