*/ public function broadcastOn(): array { return [new Channel('player.'.$this->playerId)]; } public function broadcastAs(): string { return 'balance.update'; } /** * @return array{player_id: int, currency_code: string, balance_minor: int, balance_formatted: string, change_minor: int, change_formatted: string, reason: string, emitted_at_ms: int} */ public function broadcastWith(): array { return [ 'player_id' => $this->playerId, 'currency_code' => $this->currencyCode, 'balance_minor' => $this->balanceMinor, 'balance_formatted' => number_format($this->balanceMinor / 100, 2), 'change_minor' => $this->changeMinor, 'change_formatted' => ($this->changeMinor > 0 ? '+' : '').number_format($this->changeMinor / 100, 2), 'reason' => $this->reason, 'emitted_at_ms' => $this->emittedAtMs, ]; } }