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) { try{ if($notifiable instanceof HelpTicket){ return (new MailMessage) ->line('The introduction to the notification.') ->action('Notification Action', route('help.show',['code' => $this->ticket->code])) ->line('Thank you for using our application!'); } else return (new MailMessage) ->line('You have new ticket') ->action('Notification Action', route('ticket.replay',['id'=>$this->ticket->id])) ->line('Thank you for using our application!'); Log::info('Mail Notification: ',$notifiable); } 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(); Log::info('Database Notification: ',$notifiable); } }