- Added PleskDomainService for managing domain operations (create, update, remove, get info). - Introduced PleskHostingService for provisioning hosting accounts and notifying customers. - Created PleskService for handling API requests to Plesk. - Added migration to include 'type' column in dns_manager_servers table. - Created migration for module_hosting_accounts table to track hosting subscriptions. - Created migration for module_hosting_plesk_clients table to manage Plesk client credentials. - Added email templates for notifying customers and admins about hosting account creation.
73 lines
2.7 KiB
PHP
73 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Mail\Customer;
|
|
|
|
use App\Models\Setting;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class HostingAccountCreated extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public function __construct(public array $data) {}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
$appName = $this->payload()['company_name'] ?? config('app.name', 'The Gioi So');
|
|
|
|
return new Envelope(
|
|
subject: 'Hosting của bạn đã sẵn sàng — ' . ($this->data['domain_name'] ?? '') . ' — ' . $appName,
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
$data = $this->payload();
|
|
|
|
return new Content(
|
|
view: 'emails.customer.hosting-account-created',
|
|
with: [
|
|
'appName' => $data['company_name'] ?? config('app.name', 'The Gioi So'),
|
|
'fullName' => $data['customer_name'] ?? 'Quý khách',
|
|
'domainName' => $data['domain_name'] ?? '',
|
|
'hostingPlan' => $data['hosting_plan'] ?? '',
|
|
'serverHost' => $data['server_host'] ?? '',
|
|
'ftpUsername' => $data['ftp_username'] ?? '',
|
|
'ftpPassword' => $data['ftp_password'] ?? '',
|
|
'pleskLogin' => $data['plesk_login'] ?? '',
|
|
'pleskPassword' => $data['plesk_password'] ?? '',
|
|
'pleskPanelUrl' => $data['plesk_panel_url'] ?? '',
|
|
'loginUrl' => $data['login_url'] ?? rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap',
|
|
'supportEmail' => $data['support_email'] ?? config('mail.support_email', 'support@thegioiso.com'),
|
|
'supportPhone' => $data['support_phone'] ?? config('mail.support_phone', '1900.xxxx'),
|
|
],
|
|
);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|