You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.8 KiB

  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Notifications\Messages\MailMessage;
  6. use Illuminate\Notifications\Notification;
  7. class MailNotification extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. public $message;
  11. /**
  12. * The name of the queue connection to use when queueing the notification.
  13. *
  14. * @var string
  15. */
  16. // public $connection = 'redis';
  17. /**
  18. * If your queue connection's after_commit configuration option is set to true,
  19. * indicate that a particular queued listener should be dispatched after all database transactions closed
  20. *
  21. * @var boolean
  22. */
  23. // public $afterCommit = true;
  24. /**
  25. * Determine which queues should be used for notification.
  26. *
  27. * @return string
  28. */
  29. // public $queue = 'mail-queue';
  30. /**
  31. * Create a new notification instance.
  32. *
  33. * @return void
  34. */
  35. public function __construct($message)
  36. {
  37. $this->connection = 'redis';
  38. $this->queue = 'mail-queue';
  39. $this->afterCommit = true;
  40. $this->message = $message;
  41. }
  42. /**
  43. * Get the notification's delivery channels.
  44. *
  45. * @param mixed $notifiable
  46. * @return array
  47. */
  48. public function via($notifiable)
  49. {
  50. return ['mail'];
  51. }
  52. /**
  53. * Get the mail representation of the notification.
  54. *
  55. * @param mixed $notifiable
  56. * @return \Illuminate\Notifications\Messages\MailMessage
  57. */
  58. public function toMail($notifiable)
  59. {
  60. return (new MailMessage)
  61. ->greeting($this->message['greeting'])
  62. ->line($this->message['body'])
  63. ->subject($this->message['subject'])
  64. ->action('Notification Action', url('/'));
  65. }
  66. }