Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
606 stars 64 forks source link

sqlsrv and groupBy #46

Open bdpsoft opened 7 months ago

bdpsoft commented 7 months ago

You can replace in aggregate this line ->groupBy(DB::raw($this->getSqlDate())) // ->groupBy($this->dateAlias)

and add Adapter for sqlsrv

class MssqlAdapter extends AbstractAdapter { public function format(string $column, string $interval): string { $format = match ($interval) { 'minute' => 'yyyy-MM-dd HH:mm:00', 'hour' => 'yyyy-MM-dd HH:00:00', 'day' => 'yyyy-MM-dd', 'month' => 'yyyy-MM', 'year' => 'yyyy', default => throw new Error('Invalid interval.'), };

    return "format({$column}, '{$format}')";
}

}