41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\Mail\Customer;
|
|
|
|
use App\Mail\Customer\VmRebuildFailed;
|
|
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\Mail;
|
|
|
|
class VmRebuildFailedJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public array $data;
|
|
|
|
public function __construct(array $data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
if (empty($this->data['customer_email'])) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
Mail::to($this->data['customer_email'])
|
|
->send(new VmRebuildFailed($this->data));
|
|
} catch (\Throwable $e) {
|
|
\Log::error('Không thể gửi email thông báo rebuild thất bại: ' . $e->getMessage(), [
|
|
'customer_email' => $this->data['customer_email'],
|
|
'module_vmware_id' => $this->data['module_vmware_id'] ?? null,
|
|
]);
|
|
}
|
|
}
|
|
}
|