BroadcastToStation.php 673 B

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