Files
portal-api/app/Mail/Customer/SnapshotActionMail.php
2026-10-05 09:30:24 +07:00

50 lines
1.9 KiB
PHP

<?php
namespace App\Mail\Customer;
use App\Mail\TemplateMailable;
use App\Support\MailGlobals;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
class SnapshotActionMail extends TemplateMailable
{
use Queueable, SerializesModels;
private const LABELS = [
'create' => ['icon' => '📸', 'title' => 'Tạo Snapshot thành công', 'desc' => 'Snapshot máy chủ ảo của bạn đã được tạo thành công', 'status' => 'Tạo thành công ✓'],
'remove' => ['icon' => '🗑️', 'title' => 'Xóa Snapshot thành công', 'desc' => 'Snapshot máy chủ ảo của bạn đã được xóa thành công', 'status' => 'Xóa thành công ✓'],
'revert' => ['icon' => '🔄', 'title' => 'Khôi phục Snapshot thành công', 'desc' => 'Máy chủ ảo của bạn đã được khôi phục về snapshot thành công', 'status' => 'Khôi phục thành công ✓'],
];
public function __construct(public array $data) {}
public function attachments(): array
{
return [];
}
protected function scenario(): string
{
return 'snapshot_action';
}
protected function variables(): array
{
$data = [...MailGlobals::values(), ...$this->data];
$label = self::LABELS[$data['action'] ?? 'create'] ?? self::LABELS['create'];
return [
'app_name' => $data['company_name'] ?? config('app.name', 'The Gioi So'),
'full_name' => $data['fullname'] ?? 'Quý khách',
'vm_name' => $data['vm_name'] ?? '',
'snapshot_name' => $data['snapshot_name'] ?? '',
'action_at' => $data['action_at'] ?? now()->format('d/m/Y H:i:s'),
'action_icon' => $label['icon'],
'action_title' => $label['title'],
'action_desc' => $label['desc'],
'action_status' => $label['status'],
];
}
}