InteractsWithSockets.php 669B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Illuminate\Broadcasting;
  3. use Illuminate\Support\Facades\Broadcast;
  4. trait InteractsWithSockets
  5. {
  6. /**
  7. * The socket ID for the user that raised the event.
  8. *
  9. * @var string|null
  10. */
  11. public $socket;
  12. /**
  13. * Exclude the current user from receiving the broadcast.
  14. *
  15. * @return $this
  16. */
  17. public function dontBroadcastToCurrentUser()
  18. {
  19. $this->socket = Broadcast::socket();
  20. return $this;
  21. }
  22. /**
  23. * Broadcast the event to everyone.
  24. *
  25. * @return $this
  26. */
  27. public function broadcastToEveryone()
  28. {
  29. $this->socket = null;
  30. return $this;
  31. }
  32. }