rider->id}.location"), ]; // Broadcast to all active delivery channels for this rider foreach ($this->rider->activeDeliveries as $delivery) { $channels[] = new Channel("delivery.{$delivery->tracking_code}"); } return $channels; } /** * Get the data to broadcast. */ public function broadcastWith(): array { return [ 'rider_id' => $this->rider->id, 'location' => [ 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'speed' => $this->speed, 'bearing' => $this->bearing, ], 'timestamp' => now()->toIso8601String(), ]; } /** * The event's broadcast name. */ public function broadcastAs(): string { return 'rider.location.updated'; } }