AdminCreateNotification.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Notifications\Ticket\Admin;
  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 AdminCreateNotification 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. /**
  16. * Create a new notification instance.
  17. *
  18. * @return void
  19. */
  20. public function __construct(Ticket $ticket, User $user)
  21. {
  22. $this->ticket = $ticket;
  23. $this->user = $user;
  24. }
  25. /**
  26. * Get the notification's delivery channels.
  27. *
  28. * @param mixed $notifiable
  29. * @return array
  30. */
  31. public function via($notifiable)
  32. {
  33. $via = ['mail', 'database'];
  34. return $via;
  35. }
  36. /**
  37. * Get the mail representation of the notification.
  38. *
  39. * @param mixed $notifiable
  40. * @return MailMessage
  41. */
  42. public function toMail($notifiable)
  43. {
  44. return (new MailMessage)
  45. ->subject('[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title)
  46. ->markdown('mail.ticket.admin.create', ['ticket' => $this->ticket, 'user' => $this->user]);
  47. }
  48. /**
  49. * Get the array representation of the notification.
  50. *
  51. * @param mixed $notifiable
  52. * @return array
  53. */
  54. public function toArray($notifiable)
  55. {
  56. return [
  57. 'title' => '[Ticket ID: '.$this->ticket->ticket_id.'] '.$this->ticket->title,
  58. 'content' => "Ticket With ID : {$this->ticket->ticket_id} has been opened by <strong>{$this->user->name}</strong>",
  59. ];
  60. }
  61. }