data = $data; $this->userIds = $userIds; } /** * @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel */ public function broadcastOn() { $channels = []; if (is_array($this->userIds)) { foreach ($this->userIds as $userId) { array_push($channels, new PrivateChannel('user.'.$userId)); } return $channels; } return new PrivateChannel('user.'.$this->userIds); } /** * @return array */ public function broadcastWith() { return $this->data; } }