conversationId = $conversationId; $this->user = $user; $this->action = $action; $this->timestamp = now(); } public function broadcastOn() { // Broadcast to the conversation channel (similar to WireChat's MessageCreated event) return new PrivateChannel("conversation.{$this->conversationId}"); } public function broadcastWith() { return [ 'conversation_id' => $this->conversationId, 'user' => [ 'id' => $this->user->id, 'name' => $this->user->name, 'type' => $this->user->getMorphClass(), 'avatar' => $this->user->avatar ?? null, ], 'action' => $this->action, 'timestamp' => $this->timestamp, ]; } public function broadcastAs() { return 'WireChatUserTyping'; } }