SendEmailNotification.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 SendEmailNotification extends Notification
  8. {
  9. use Queueable;
  10. public $objToJson;
  11. /**
  12. * SendEmailNotification constructor.
  13. * @param $objToJson
  14. */
  15. public function __construct($objToJson)
  16. {
  17. $this->objToJson = $objToJson;
  18. }
  19. /**
  20. * Get the notification's delivery channels.
  21. *
  22. * @param mixed $notifiable
  23. * @return array
  24. */
  25. public function via($notifiable)
  26. {
  27. return ['mail'];
  28. }
  29. /**
  30. * Get the mail representation of the notification.
  31. *
  32. * @param mixed $notifiable
  33. * @return \Illuminate\Notifications\Messages\MailMessage
  34. */
  35. public function toMail($notifiable)
  36. {
  37. return (new MailMessage)->view(
  38. 'emails.test', ['objToJson' => json_decode($this->objToJson)]
  39. );
  40. }
  41. /**
  42. * Get the array representation of the notification.
  43. *
  44. * @param mixed $notifiable
  45. * @return array
  46. */
  47. public function toArray($notifiable)
  48. {
  49. return [
  50. //
  51. ];
  52. }
  53. }