• File: DataChangeEmailNotification.php
  • Full Path: /var/www/ticketapp/app/Notifications/DataChangeEmailNotification.php
  • Date Modified: 04/25/2022 10:28 PM
  • File size: 1.21 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;

class DataChangeEmailNotification extends Notification
{
    use Queueable;

    public function __construct($data)
    {
        $this->data = $data;
        $this->ticket = $data['ticket'];
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        return $this->getMessage();
    }

    public function getMessage()
    {
        return (new MailMessage)
            ->subject($this->data['action'])
            ->greeting('Olá,')
            ->line($this->data['action'])
            ->line("Autor: ".$this->ticket->author_name)
            ->line("Número do Ticket: ".$this->ticket->id)
            ->line("Descrição do Problema: ".Str::limit($this->ticket->content, 200))
            ->action('Visualizar o ticket', route('admin.tickets.show', $this->ticket->id))
            ->line('Obrigado')
            ->line(' iMali Support')
//            ->line(config('app.name') . ' Team')
            ->salutation(' ');
    }
}