Files
portal-api/app/Jobs/Mail/Customer/OrderPaymentSuccessJob.php
2025-07-24 16:18:27 +07:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Jobs\Mail\Customer;
use App\Mail\Customer\OrderPaymentSuccess;
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 OrderPaymentSuccessJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public array $data;
/**
* Create a new job instance.
*/
public function __construct(array $data)
{
$this->data = $data;
}
/**
* Execute the job.
*/
public function handle(): void
{
try {
Mail::to($this->data['customer_email'])
->send(new OrderPaymentSuccess($this->data));
} catch (\Throwable $e) {
\Log::error('Không thể gửi email thông báo thành công: ' . $e->getMessage(), [
'customer_email' => $this->data['customer_email'],
'order_id' => $this->data['order_id'] ?? null
]);
}
}
}