ReplyNotification.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Notifications\Ticket\User;
  3. use App\Models\Ticket;
  4. use App\Models\User;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Notifications\Messages\MailMessage;
  8. use Illuminate\Notifications\Notification;
  9. class ReplyNotification extends Notification implements ShouldQueue
  10. {
  11. //THIS IS BASICALLY NOT USED ANYMORE WITH INVOICENOTIFICATION IN PLACE
  12. use Queueable;
  13. private Ticket $ticket;
  14. private User $user;
  15. private $newmessage;
  16. /**
  17. * Create a new notification instance.
  18. *
  19. * @return void
  20. */
  21. public function __construct(Ticket $ticket, User $user, $newmessage)
  22. {
  23. $this->ticket = $ticket;
  24. $this->user = $user;
  25. $this->newmessage = $newmessage;
  26. }
  27. /**
  28. * Get the notification's delivery channels.
  29. *
  30. * @param mixed $notifiable
  31. * @return array
  32. */
  33. public function via($notifiable)
  34. {
  35. $via = ['mail', 'database'];
  36. return $via;
  37. }
  38. /**
  39. * Get the mail representation of the notification.
  40. *
  41. * @param mixed $notifiable
  42. * @return MailMessage
  43. */
  44. public function toMail($notifiable)
  45. {
  46. return (new MailMessage)
  47. ->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
  48. ->markdown('mail.ticket.user.reply', ['ticket' => $this->ticket, 'user' => $this->user, 'newmessage' => $this->newmessage]);
  49. }
  50. /**
  51. * Get the array representation of the notification.
  52. *
  53. * @param mixed $notifiable
  54. * @return array
  55. */
  56. public function toArray($notifiable)
  57. {
  58. return [
  59. 'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
  60. 'content' => "
  61. <p>Ticket With ID : {$this->ticket->ticket_id} A response has been added to your ticket. Please see below for our response!</p>
  62. <br>
  63. <p><strong>Message:</strong></p>
  64. <p>{$this->newmessage}</p>
  65. ",
  66. ];
  67. }
  68. }