message = $message; $this->data = $data; $this->type = $type; } // 定义事件要广播到的公共频道 public function broadcastOn(): array { return [ new Channel('channel-pub'), // 公共频道 ]; } // 可选:自定义广播数据 public function broadcastWith(): array { return [ 'message' => $this->message, 'data' => $this->data, 'type' => $this->type, 'time' => now()->toDateTimeString(), ]; } }