/** * @param string $func * @param string $column * @param \anlutro\LaravelRepository\CriteriaInterface[] $criteria * @return array */ protected function aggregateInterval($func, $column, array $criteria = []) { $query = $this->db->table($this->model->getTable()); $this->interval->applyQuery($query); array_map(function ($criteria) use($query) { $criteria->apply($query); }, $criteria); $expression = $this->db->raw("{$func}({$column}) as `__aggregate__`"); $query->addSelect($expression); return $this->interval->parse($query->get(), $this->start, $this->end); }