*/ public function broadcastOn(): array { return [new PresenceChannel('room.'.$this->roomId)]; } /** * 广播数据:前端渲染红包弹窗所需字段。 * * @return array */ public function broadcastWith(): array { return [ 'envelope_id' => $this->envelopeId, 'sender_username' => $this->senderUsername, 'total_amount' => $this->totalAmount, 'total_count' => $this->totalCount, 'expire_seconds' => $this->expireSeconds, 'type' => $this->type, ]; } /** 自定义事件名称(前端监听时使用)。 */ public function broadcastAs(): string { return 'red-packet.sent'; } }