update email template

This commit is contained in:
baodev0
2026-09-09 16:56:22 +07:00
parent d3d9f76ba0
commit 2365ef72e9
210 changed files with 6335 additions and 4688 deletions
+5 -8
View File
@@ -2,15 +2,14 @@
namespace App\Jobs\Mail\Customer;
use App\Mail\Customer\OrderCreated;
use App\Models\Template;
use App\Services\Email\EmailTemplateService;
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
{
@@ -18,17 +17,15 @@ class OrderCreatedJob implements ShouldQueue
public function __construct(public readonly array $data) {}
public function handle(): void
public function handle(EmailTemplateService $emailTemplateService): void
{
$template = Template::where('name', 'Order Created')->where('status', 1)->first();
if (!$template) {
Log::warning('OrderCreatedJob: Template "Order Created" not found or inactive.');
if (!Template::where('scenario', 'order_created')->where('status', 1)->exists()) {
Log::warning('OrderCreatedJob: Template "order_created" not found or inactive.');
return;
}
try {
Mail::to($this->data['customer_email'])->send(new OrderCreated($template, $this->data));
$emailTemplateService->send('order_created', $this->data['customer_email'], $this->data);
} catch (\Throwable $e) {
Log::error('OrderCreatedJob: Failed to send email. ' . $e->getMessage(), [
'customer_email' => $this->data['customer_email'],