ctrlpanel/app/Notifications/Ticket/User/ReplyNotification.php

81 lines
2 KiB
PHP
Raw Normal View History

2022-08-01 16:52:16 +00:00
<?php
namespace App\Notifications\Ticket\User;
use App\Models\Ticket;
use App\Models\User;
2022-08-01 16:52:16 +00:00
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class ReplyNotification extends Notification implements ShouldQueue
{
//THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
use Queueable;
private Ticket $ticket;
2022-08-01 16:52:16 +00:00
private User $user;
2022-08-01 16:52:16 +00:00
private $newmessage;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Ticket $ticket, User $user, $newmessage)
{
$this->ticket = $ticket;
$this->user = $user;
2022-08-01 16:52:16 +00:00
$this->newmessage = $newmessage;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
$via = ['mail', 'database'];
2022-08-01 16:52:16 +00:00
return $via;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
->markdown('mail.ticket.user.reply', ['ticket' => $this->ticket, 'user' => $this->user, 'newmessage' => $this->newmessage]);
2022-08-01 16:52:16 +00:00
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
2022-08-01 16:52:16 +00:00
* @return array
*/
public function toArray($notifiable)
{
return [
'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
2022-08-01 16:52:16 +00:00
'content' => "
<p>Ticket With ID : {$this->ticket->ticket_id} A response has been added to your ticket. Please see below for our response!</p>
<br>
<p><strong>Message:</strong></p>
<p>{$this->newmessage}</p>
",
];
}
}