/** * Собирает и отправляет запрос * Вызывать после чейнинга методов выборки, группировки и тд * @return array */ public function aggregate() { $result = $this->model->getCollection()->aggregate($this->aggregationPipeline); $this->aggregationPipeline = []; if (isset($result['result']) && isset($result['result'])) { return $result['result']; } return $result; }