public function getPipeline() { $pipeline = parent::getPipeline(); if ($this->getStage(0) instanceof GeoNear) { $pipeline[0]['$geoNear']['query'] = $this->applyFilters($pipeline[0]['$geoNear']['query']); } else { $matchStage = $this->applyFilters([]); if ($matchStage !== []) { array_unshift($pipeline, ['$match' => $matchStage]); } } return $pipeline; }