diff --git a/src/Trend.php b/src/Trend.php index 02fb3a7..af53ce3 100755 --- a/src/Trend.php +++ b/src/Trend.php @@ -21,6 +21,8 @@ class Trend public string $dateColumn = 'created_at'; + public string $dateAlias = 'date'; + public function __construct(public Builder $builder) { } @@ -87,12 +89,12 @@ public function aggregate(string $column, string $aggregate): Collection $values = $this->builder ->toBase() ->selectRaw(" - {$this->getSqlDate()} as date, + {$this->getSqlDate()} as {$this->dateAlias}, {$aggregate}({$column}) as aggregate ") ->whereBetween($this->dateColumn, [$this->start, $this->end]) - ->groupBy('date') - ->orderBy('date') + ->groupBy($this->dateAlias) + ->orderBy($this->dateAlias) ->get(); return $this->mapValuesToDates($values);