ticket = $ticket; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return $notifiable instanceof HelpTicket ? ['mail'] : ['mail','database']; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { Log::info($notifiable); try{ if($notifiable instanceof HelpTicket){ return (new MailMessage)->from(config('mail.from_help.address'),config('mail.from.name')) ->view('Emails.Help.CustomerNotification',['ticket' => $this->ticket]); } else return (new MailMessage) ->from(config('mail.from_help.address'),config('mail.from.name')) ->line('You have new ticket') ->line($this->ticket->text) ->line($this->ticket->created_at) ->action('Reply here', route('ticket.replay',['id'=>$this->ticket->id])) ->line('Thank you for using our application!'); } catch (\Exception $ex){ Log::error($ex); } } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toDatabase($notifiable) { return $this->ticket->toArray(); } }