queue = 'high'; $this->delay = config('queue.connections.database.delay'); $this->invoice = $invoice; } /** * Get the notification's channels. * * @param mixed $notifiable * @return array|string */ public function via($notifiable) { return ['mail', 'database']; } /** * Build the mail representation of the notification. * * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { $message = (new MailMessage) ->line(trans('invoices.notification.message', ['amount' => money($this->invoice->amount, $this->invoice->currency_code, true), 'customer' => $this->invoice->customer_name])); // Override per company as Laravel doesn't read config $message->from(config('mail.from.address'), config('mail.from.name')); // Attach the PDF file if available if (isset($this->invoice->pdf_path)) { $message->attach($this->invoice->pdf_path, [ 'mime' => 'application/pdf', ]); } if ($this->invoice->customer->user) { $message->action(trans('invoices.notification.button'), url('customers/invoices', $this->invoice->id, true)); } return $message; } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ 'invoice_id' => $this->invoice->id, 'amount' => $this->invoice->amount, ]; } }