*/ public function broadcastOn(): array { return [new PresenceChannel('room.1')]; } /** * 广播事件名(前端监听 .horse.opened)。 */ public function broadcastAs(): string { return 'horse.opened'; } /** * 广播数据。 * * @return array */ public function broadcastWith(): array { return [ 'race_id' => $this->race->id, 'horses' => $this->race->horses, 'total_pool' => $this->race->total_pool, 'bet_opens_at' => $this->race->bet_opens_at->toIso8601String(), 'bet_closes_at' => $this->race->bet_closes_at->toIso8601String(), 'bet_seconds' => (int) now()->diffInSeconds($this->race->bet_closes_at), ]; } }