*/ public function broadcastOn(): array { return [ new PresenceChannel('room.'.$this->roomId), ]; } /** * 获取广播时的数据 * * @return array */ public function broadcastWith(): array { $statusMessage = $this->message ?: ($this->muteTime > 0 ? "管理员 [{$this->operator}] 已将 [{$this->username}] 禁言 {$this->muteTime} 分钟。" : "用户 [{$this->username}] 已被解除禁言。"); return [ 'username' => $this->username, 'mute_time' => $this->muteTime, 'operator' => $this->operator, 'message' => $statusMessage, ]; } }