['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 envelope(): Envelope { return new Envelope( subject: $this->renderFromTemplate('snapshot_action', $this->vars())['subject'], ); } public function content(): Content { return new Content( htmlString: $this->renderFromTemplate('snapshot_action', $this->vars())['html'], ); } public function attachments(): array { return []; } private function payload(): array { try { $setting = Setting::where('key', 'setting')->first(); $settingValue = $setting ? json_decode((string) $setting->value, true) : []; } catch (\Throwable) { $settingValue = []; } return array_merge([ 'company_name' => $settingValue['company'] ?? config('app.name', 'The Gioi So'), 'support_email' => $settingValue['email'] ?? config('mail.support_email', 'support@thegioiso.com'), 'support_phone' => $settingValue['hotline'] ?? ($settingValue['phone'] ?? config('mail.support_phone', '1900.xxxx')), 'login_url' => rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap', ], $this->data); } private function vars(): array { $data = $this->payload(); $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'], 'login_url' => $data['login_url'] ?? rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap', 'support_email' => $data['support_email'] ?? config('mail.support_email', 'support@thegioiso.com'), 'support_phone' => $data['support_phone'] ?? config('mail.support_phone', '1900.xxxx'), ]; } }