customer; if (! $customer) { return; } $name = $service->server_name ?: $service->orderItem?->product?->name ?: 'Dịch vụ'; $invoice->setRelation('order', $service->orderItem?->order); Notification::notifyCustomer($customer, [ 'type' => 'renewal_invoice', 'title' => 'Hóa đơn gia hạn dịch vụ', 'body' => sprintf( 'Dịch vụ %s hết hạn ngày %s. Hóa đơn gia hạn #%s (%s VNĐ) đang chờ thanh toán.', $name, $service->expires_at?->format('d/m/Y') ?? '-', $invoice->invoice_number, number_format((int) $invoice->total, 0, ',', '.'), ), 'link' => $invoice->clientPath(), 'data' => ['invoice_number' => $invoice->invoice_number, 'service_id' => $service->id], ]); if ($customer->email && AutoEmailGate::allows(InvoiceNotificationMail::SCENARIO)) { SendInvoiceMailJob::dispatch($invoice->id, 'renewal', null, null, null, null)->afterCommit(); } } }