Files
portal-api/app/Jobs/Mail/Admin/HostingAccountCreatedAdminNotificationJob.php
T
baodev0 d6d63e5152 feat: Implement Plesk domain and hosting services
- 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.
2026-08-06 17:24:01 +07:00

60 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Jobs\Mail\Admin;
use App\Mail\Admin\HostingAccountCreatedAdminNotification;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
class HostingAccountCreatedAdminNotificationJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $timeout = 60;
public function __construct(public readonly array $data) {}
public function handle(): void
{
$setting = Setting::where('key', 'setting')->first();
$settingValue = $setting ? json_decode((string) $setting->value, true) : [];
$adminEmail = $settingValue['admin_email'] ?? null;
if (empty($adminEmail)) {
Log::warning('HostingAccountCreatedAdminNotificationJob: admin_email not configured in settings.');
return;
}
$payload = array_merge($this->data, [
'company_name' => $settingValue['company'] ?? 'Portal Admin',
]);
try {
Mail::to($adminEmail)->send(new HostingAccountCreatedAdminNotification($payload));
} catch (\Throwable $e) {
Log::error('HostingAccountCreatedAdminNotificationJob: failed to send email. ' . $e->getMessage(), [
'admin_email' => $adminEmail,
'domain_name' => $this->data['domain_name'] ?? null,
]);
}
}
public function failed(\Throwable $e): void
{
Log::error('HostingAccountCreatedAdminNotificationJob: job failed.', [
'error' => $e->getMessage(),
'domain_name' => $this->data['domain_name'] ?? null,
]);
}
}