CreateNotification.php 1.6 KB

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