query = $this->model instanceof Builder ? $this->model->clone() : (new $this->model())->newQuery(); if (!$this->dateColumn) { $this->dateColumn = $this->query ->getModel() ->getQualifiedCreatedAtColumn(); } } public function count(): array { return $this->aggregate('count'); } public function average(): array { return $this->aggregate('avg'); } public function sum(): array { return $this->aggregate('sum'); } public function max(): array { return $this->aggregate('max'); } public function min(): array { return $this->aggregate('min'); } abstract protected function aggregate(string $function); protected function getWrappedColumn(): string { $column = $this->column ?: $this->query->getModel()->getQualifiedKeyName(); return $column instanceof Expression ? (string) $column : $this->query ->getQuery() ->getGrammar() ->wrap($column); } protected function round(int|float $value): float { return round($value, $this->roundingPrecision, $this->roundingMode); } }