NewChatComment.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Events\LiveStream;
  3. use Illuminate\Broadcasting\Channel;
  4. use Illuminate\Broadcasting\InteractsWithSockets;
  5. use Illuminate\Broadcasting\PresenceChannel;
  6. use Illuminate\Broadcasting\PrivateChannel;
  7. use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  8. use Illuminate\Foundation\Events\Dispatchable;
  9. use Illuminate\Queue\SerializesModels;
  10. use App\Models\LiveStream;
  11. class NewChatComment implements ShouldBroadcast
  12. {
  13. use Dispatchable, InteractsWithSockets, SerializesModels;
  14. public $livestream;
  15. public $chatmsg;
  16. /**
  17. * Create a new event instance.
  18. *
  19. * @return void
  20. */
  21. public function __construct(LiveStream $livestream, $chatmsg)
  22. {
  23. $this->livestream = $livestream;
  24. $this->chatmsg = $chatmsg;
  25. }
  26. /**
  27. * Get the channels the event should broadcast on.
  28. *
  29. * @return \Illuminate\Broadcasting\Channel|array
  30. */
  31. public function broadcastOn()
  32. {
  33. return new Channel('live.chat.' . $this->livestream->profile_id);
  34. }
  35. public function broadcastAs()
  36. {
  37. return 'chat.new-message';
  38. }
  39. public function broadcastWith()
  40. {
  41. return ['msg' => $this->chatmsg];
  42. }
  43. }