update email template
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -12,23 +13,21 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class AdminOrderNotification extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(public readonly array $data) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: '[ADMIN] Đơn hàng mới #' . ($this->data['order_num'] ?? 'N/A')
|
||||
. ' — ' . ($this->data['customer_email'] ?? ''),
|
||||
subject: $this->renderFromTemplate('admin_order_notification', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.admin.order-notification',
|
||||
with: $this->data,
|
||||
htmlString: $this->renderFromTemplate('admin_order_notification', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,4 +35,33 @@ class AdminOrderNotification extends Mailable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
$vmFields = ['ip' => '🌐 IP Address', 'username' => '👤 Username', 'password' => '🔑 Password'];
|
||||
$vmRows = '';
|
||||
foreach ($vmFields as $field => $label) {
|
||||
if (!empty($this->data[$field])) {
|
||||
$vmRows .= '<div class="vm-row"><span class="vm-label">' . $label . '</span><span class="vm-value">' . e($this->data[$field]) . '</span></div>';
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'order_num' => $this->data['order_num'] ?? 'N/A',
|
||||
'created_at' => $this->data['created_at'] ?? now()->format('d/m/Y H:i:s'),
|
||||
'customer_name' => $this->data['customer_name'] ?? 'N/A',
|
||||
'customer_email' => $this->data['customer_email'] ?? 'N/A',
|
||||
'client_ip_row' => !empty($this->data['client_ip'])
|
||||
? '<tr><td>IP đặt hàng</td><td>' . e($this->data['client_ip']) . '</td></tr>'
|
||||
: '',
|
||||
'product_name' => $this->data['product_name'] ?? 'N/A',
|
||||
'product_type' => $this->data['product_type'] ?? 'N/A',
|
||||
'billing_cycle' => $this->data['billing_cycle'] ?? 'N/A',
|
||||
'total_formatted' => number_format((float) ($this->data['total'] ?? 0), 0, ',', '.') . ' VNĐ',
|
||||
'vm_block' => $vmRows
|
||||
? '<div class="section-label">Thông tin dịch vụ Cloud VPS</div><div class="vm-box">' . $vmRows . '</div>'
|
||||
: '',
|
||||
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
@@ -11,7 +12,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DomainOrderNewNotification extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(
|
||||
protected array $data,
|
||||
@@ -20,19 +21,28 @@ class DomainOrderNewNotification extends Mailable implements ShouldQueue
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: "[ADMIN] Đơn đăng ký tên miền mới - {$this->data['domain_name']}",
|
||||
subject: $this->renderFromTemplate('admin_domain_order_new', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.layouts.notification',
|
||||
with: [
|
||||
'companyName' => $this->data['company_name'] ?? config('app.name'),
|
||||
'title' => 'Thông báo đơn đăng ký tên miền mới',
|
||||
'body' => view('emails.admin.domain-order-new', $this->data)->render(),
|
||||
],
|
||||
htmlString: $this->renderFromTemplate('admin_domain_order_new', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
return [
|
||||
'company_name' => $this->data['company_name'] ?? config('app.name'),
|
||||
'domain_name' => $this->data['domain_name'] ?? '',
|
||||
'order_num' => $this->data['order_num'] ?? '',
|
||||
'order_total' => $this->data['order_total'] ?? '',
|
||||
'customer_name' => $this->data['customer_name'] ?? '',
|
||||
'customer_email' => $this->data['customer_email'] ?? '',
|
||||
'created_at' => $this->data['created_at'] ?? now()->format('d/m/Y H:i:s'),
|
||||
'admin_url' => $this->data['admin_url'] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -12,22 +13,21 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class HostingAccountCreatedAdminNotification extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(public readonly array $data) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: '[ADMIN] Hosting account mới — ' . ($this->data['domain_name'] ?? 'N/A'),
|
||||
subject: $this->renderFromTemplate('admin_hosting_account_created', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.admin.hosting-account-created',
|
||||
with: $this->data,
|
||||
htmlString: $this->renderFromTemplate('admin_hosting_account_created', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,4 +35,29 @@ class HostingAccountCreatedAdminNotification extends Mailable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
$row = fn (string $label, ?string $value) => $value
|
||||
? '<div class="cred-row"><span class="cred-label">' . $label . '</span><span class="cred-value">' . e($value) . '</span></div>'
|
||||
: '';
|
||||
|
||||
return [
|
||||
'domain_name' => $this->data['domain_name'] ?? 'N/A',
|
||||
'created_at' => $this->data['created_at'] ?? now()->format('d/m/Y H:i:s'),
|
||||
'customer_name' => $this->data['customer_name'] ?? 'N/A',
|
||||
'customer_email' => $this->data['customer_email'] ?? 'N/A',
|
||||
'hosting_plan' => $this->data['hosting_plan'] ?? 'N/A',
|
||||
'server_name' => $this->data['server_name'] ?? 'N/A',
|
||||
'server_ip' => $this->data['server_ip'] ?? 'N/A',
|
||||
'plesk_client_id' => $this->data['plesk_client_id'] ?? 'N/A',
|
||||
'plesk_subscription_id' => $this->data['plesk_subscription_id'] ?? 'N/A',
|
||||
'ftp_username' => $this->data['ftp_username'] ?? 'N/A',
|
||||
'ftp_password_row' => $row('🔑 FTP Password', $this->data['ftp_password'] ?? null),
|
||||
'plesk_panel_url' => $this->data['plesk_panel_url'] ?? 'N/A',
|
||||
'plesk_login' => $this->data['plesk_login'] ?? 'N/A',
|
||||
'plesk_password_row' => $row('🔑 Password', $this->data['plesk_password'] ?? null),
|
||||
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -10,22 +11,21 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ManualDepositPendingNotification extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(public array $data) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: '[ADMIN] Yêu cầu nạp tiền chờ duyệt - ' . ($this->data['transaction_code'] ?? 'N/A'),
|
||||
subject: $this->renderFromTemplate('admin_manual_deposit_pending', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.admin.manual-deposit-pending',
|
||||
with: $this->data,
|
||||
htmlString: $this->renderFromTemplate('admin_manual_deposit_pending', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,4 +33,25 @@ class ManualDepositPendingNotification extends Mailable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
return [
|
||||
'transaction_code' => $this->data['transaction_code'] ?? 'N/A',
|
||||
'created_at' => $this->data['created_at'] ?? now()->format('d/m/Y H:i:s'),
|
||||
'customer_name' => $this->data['customer_name'] ?? 'N/A',
|
||||
'customer_email' => $this->data['customer_email'] ?? 'N/A',
|
||||
'customer_phone_row' => !empty($this->data['customer_phone'])
|
||||
? '<tr><td>Số điện thoại</td><td>' . e($this->data['customer_phone']) . '</td></tr>'
|
||||
: '',
|
||||
'client_ip_row' => !empty($this->data['client_ip'])
|
||||
? '<tr><td>IP gửi yêu cầu</td><td>' . e($this->data['client_ip']) . '</td></tr>'
|
||||
: '',
|
||||
'amount_formatted' => number_format((float) ($this->data['amount'] ?? 0), 0, ',', '.') . ' VNĐ',
|
||||
'proof_row' => !empty($this->data['proof_image_url'])
|
||||
? '<tr><td>Chứng từ</td><td><a href="' . e($this->data['proof_image_url']) . '">Xem chứng từ chuyển khoản</a></td></tr>'
|
||||
: '',
|
||||
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,33 +2,49 @@
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TicketAdminNotification extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(
|
||||
public readonly mixed $ticket,
|
||||
public readonly mixed $customer,
|
||||
) {}
|
||||
|
||||
public function build(): static
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return $this
|
||||
->subject("[ADMIN] Ticket mới #{$this->ticket->ticket_num} — {$this->customer->email}")
|
||||
->view('emails.admin.ticket-notification')
|
||||
->with([
|
||||
'ticketNum' => $this->ticket->ticket_num,
|
||||
'subject' => $this->ticket->subject,
|
||||
'room' => $this->ticket->room,
|
||||
'description' => strip_tags($this->ticket->description),
|
||||
'customerName' => trim($this->customer->firstname . ' ' . $this->customer->lastname),
|
||||
'customerEmail' => $this->customer->email,
|
||||
'ticketUrl' => config('app.frontend_url') . '/tickets/' . $this->ticket->ticket_num,
|
||||
]);
|
||||
return new Envelope(
|
||||
subject: $this->renderFromTemplate('admin_ticket_notification', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
htmlString: $this->renderFromTemplate('admin_ticket_notification', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
$description = strip_tags($this->ticket->description ?? '');
|
||||
|
||||
return [
|
||||
'ticket_num' => $this->ticket->ticket_num,
|
||||
'subject_text' => $this->ticket->subject,
|
||||
'room' => $this->ticket->room ?? 'N/A',
|
||||
'customer_name' => trim($this->customer->firstname . ' ' . $this->customer->lastname) ?: 'N/A',
|
||||
'customer_email'=> $this->customer->email,
|
||||
'description' => mb_substr($description, 0, 500) . (mb_strlen($description) > 500 ? '…' : ''),
|
||||
'ticket_url' => config('app.frontend_url') . '/tickets/' . $this->ticket->ticket_num,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail\Admin;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -10,22 +11,21 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TrialRegistrationRequest extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
|
||||
public function __construct(public array $data) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: '[ADMIN] Yêu cầu dùng thử Cloud VPS - ' . ($this->data['customer_name'] ?? 'N/A'),
|
||||
subject: $this->renderFromTemplate('admin_trial_registration_request', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.admin.trial-registration-request',
|
||||
with: $this->data,
|
||||
htmlString: $this->renderFromTemplate('admin_trial_registration_request', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,4 +33,22 @@ class TrialRegistrationRequest extends Mailable
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
{
|
||||
return [
|
||||
'customer_name' => $this->data['customer_name'] ?? 'N/A',
|
||||
'customer_email' => $this->data['customer_email'] ?? 'N/A',
|
||||
'customer_phone' => $this->data['customer_phone'] ?? 'N/A',
|
||||
'cpu' => $this->data['cpu'] ?? '-',
|
||||
'ram' => $this->data['ram'] ?? '-',
|
||||
'ssd' => $this->data['ssd'] ?? '-',
|
||||
'os' => $this->data['os'] ?? '-',
|
||||
'other_row' => !empty($this->data['other'])
|
||||
? '<tr><td>Yêu cầu khác</td><td>' . e($this->data['other']) . '</td></tr>'
|
||||
: '',
|
||||
'company_name' => $this->data['company_name'] ?? 'Portal Admin',
|
||||
'created_at' => $this->data['created_at'] ?? now()->format('d/m/Y H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user