<?php
 namespace App\Notifications; use App\Models\InvoiceBillingJob; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class BillingFailureNotification extends Notification implements ShouldQueue { use Queueable; public InvoiceBillingJob $job; public string $errorMessage; public function __construct(InvoiceBillingJob $job, string $errorMessage) { $this->job = $job; $this->errorMessage = $errorMessage; } public function via(object $notifiable): array { return ['mail']; } public function toMail(object $notifiable): MailMessage { $module = $this->job->billingModule; $invoice = $this->job->invoice; return (new MailMessage) ->error() ->subject(__('admin/common.notifications_billing_failure_subject', ['module' => ($module->display_name ?? $module->name)])) ->line(__('admin/common.notifications_billing_failure_line1')) ->line(__('admin/common.notifications_billing_failure_module', ['module' => ($module->display_name ?? $module->name)])) ->line(__('admin/common.notifications_billing_failure_invoice', ['invoice' => ($invoice->invoice_number ?? '#'.$invoice->id)])) ->line(__('admin/common.notifications_billing_failure_error', ['error' => $this->errorMessage])) ->line(__('admin/common.notifications_billing_failure_date', ['date' => now()->format('d.m.Y H:i:s')])) ->action(__('admin/common.notifications_billing_failure_action'), route('admin.invoice-billings.index')) ->line(__('admin/common.notifications_billing_failure_line2')); } public function toArray(object $notifiable): array { return [ 'job_id' => $this->job->id, 'module_name' => $this->job->billingModule->name, 'invoice_id' => $this->job->invoice_id, 'error_message' => $this->errorMessage, 'timestamp' => now(), ]; } } 