BroadcastToStation.php 720 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Events;
  3. use Illuminate\Broadcasting\Channel;
  4. use Illuminate\Broadcasting\PresenceChannel;
  5. use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  6. class BroadcastToStation implements ShouldBroadcast
  7. {
  8. public $json;
  9. private $id;
  10. /**
  11. * Create a new event instance.
  12. *
  13. * @param int $id
  14. * @param string $json
  15. * @return void
  16. */
  17. public function __construct(int $id, string $json)
  18. {
  19. $this->id = $id;
  20. $this->json = $json;
  21. }
  22. /**
  23. * Get the channels the event should broadcast on.
  24. *
  25. * @return Channel|array
  26. */
  27. public function broadcastOn()
  28. {
  29. return new PresenceChannel('station-'.$this->id);
  30. }
  31. }