Files
portal-api/app/Mail/Admin/HostingAccountCreatedAdminNotification.php
T
2026-09-09 16:56:22 +07:00

64 lines
2.4 KiB
PHP

<?php
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;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class HostingAccountCreatedAdminNotification extends Mailable
{
use Queueable, SerializesModels, RequiresDbTemplate;
public function __construct(public readonly array $data) {}
public function envelope(): Envelope
{
return new Envelope(
subject: $this->renderFromTemplate('admin_hosting_account_created', $this->vars())['subject'],
);
}
public function content(): Content
{
return new Content(
htmlString: $this->renderFromTemplate('admin_hosting_account_created', $this->vars())['html'],
);
}
public function attachments(): array
{
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',
];
}
}