CommentPosted.php 888 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Events;
  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\Comment;
  11. class CommentPosted
  12. {
  13. use Dispatchable, InteractsWithSockets, SerializesModels;
  14. /**
  15. * Create a new event instance.
  16. */
  17. public function __construct(Comment $comment)
  18. {
  19. //
  20. $this->comment = $comment;
  21. }
  22. /**
  23. * Get the channels the event should broadcast on.
  24. *
  25. * @return array<int, \Illuminate\Broadcasting\Channel>
  26. */
  27. public function broadcastOn(): array
  28. {
  29. return [
  30. new PrivateChannel('channel-name'),
  31. ];
  32. }
  33. }