feat: Reorganize database migrations for module snapshots, VMware, and OS groups, and implement customer order creation email notifications.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Mail\Customer;
|
||||
|
||||
use App\Mail\Customer\OrderCreated;
|
||||
use App\Models\Template;
|
||||
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 OrderCreatedJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(public readonly array $data) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$template = Template::where('name', 'Order Created')->where('status', 1)->first();
|
||||
|
||||
if (!$template) {
|
||||
Log::warning('OrderCreatedJob: Template "Order Created" not found or inactive.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to($this->data['customer_email'])->send(new OrderCreated($template, $this->data));
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('OrderCreatedJob: Failed to send email. ' . $e->getMessage(), [
|
||||
'customer_email' => $this->data['customer_email'],
|
||||
'order_num' => $this->data['order_num'] ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user