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.

51 lines
984 B

  1. <?php
  2. namespace App\Notifications;
  3. use App\Channels\Messages\FcmMessage;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Notifications\Notification;
  6. class FcmNotification extends Notification
  7. {
  8. use Queueable;
  9. public $message;
  10. /**
  11. * Create a new notification instance.
  12. *
  13. * @return void
  14. */
  15. public function __construct($message)
  16. {
  17. $this->message = $message;
  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 ['fcm'];
  28. }
  29. /**
  30. * Get the voice representation of the notification.
  31. *
  32. * @param mixed $notifiable
  33. * @return FCMMessage
  34. */
  35. public function toFcm($notifiable)
  36. {
  37. return (new FcmMessage())
  38. ->data([
  39. 'title' => $this->message['title'],
  40. 'body' => $this->message['body'],
  41. ]);
  42. }
  43. }