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.

52 lines
1.1 KiB

  1. <?php
  2. namespace App\Notifications;
  3. use App\Channels\Messages\SocketMessage;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Notifications\Messages\MailMessage;
  7. use Illuminate\Notifications\Notification;
  8. class SocketNotification extends Notification
  9. {
  10. use Queueable;
  11. public $message;
  12. /**
  13. * Create a new notification instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct($message)
  18. {
  19. $this->message = $message;
  20. }
  21. /**
  22. * Get the notification's delivery channels.
  23. *
  24. * @param mixed $notifiable
  25. * @return array
  26. */
  27. public function via($notifiable)
  28. {
  29. return ['socket'];
  30. }
  31. /**
  32. * Get the socket representation of the notification.
  33. *
  34. * @param mixed $notifiable
  35. * @return SocketMessage
  36. */
  37. public function toSocket($notifiable)
  38. {
  39. return (new SocketMessage())
  40. ->data([
  41. 'message' => $this->message['message'],
  42. 'payload' => $this->message['payload'],
  43. ]);
  44. }
  45. }