*/ public function broadcastOn(): array { return [ new PresenceChannel('room.'.$this->roomId), new PrivateChannel('user.'.$this->claimer->id), ]; } /** * 广播领取结果与剩余份数。 * * @return array */ public function broadcastWith(): array { $typeLabel = $this->type === 'exp' ? '经验' : '金币'; return [ 'envelope_id' => $this->envelopeId, 'claimer_id' => $this->claimer->id, 'claimer_username' => $this->claimer->username, 'amount' => $this->amount, 'remaining_count' => $this->remainingCount, 'type' => $this->type, 'message' => "🧧 成功抢到 {$this->amount} {$typeLabel}礼包!", ]; } /** 广播事件名称。 */ public function broadcastAs(): string { return 'red-packet.claimed'; } }