*/ public function broadcastOn(): array { return [new PresenceChannel('room.1')]; } /** * 广播数据(前端据此展示红包弹窗及新人信息)。 * * @return array */ public function broadcastWith(): array { $this->marriage->load(['user:id,username,headface', 'partner:id,username,headface', 'ringItem:id,name,icon']); return [ 'ceremony_id' => $this->ceremony->id, 'tier_name' => $this->ceremony->tier?->name ?? '婚礼', 'tier_icon' => $this->ceremony->tier?->icon ?? '🎊', 'total_amount' => $this->ceremony->total_amount, 'expires_at' => $this->ceremony->expires_at, 'user' => $this->marriage->user?->only(['id', 'username', 'headface']), 'partner' => $this->marriage->partner?->only(['id', 'username', 'headface']), 'ring' => $this->marriage->ringItem?->only(['name', 'icon']), ]; } /** 广播事件名称。 */ public function broadcastAs(): string { return 'wedding.celebration'; } }