diff --git a/src/Adapters/MySqlAdapter.php b/src/Adapters/MySqlAdapter.php index 74d6d5a..9ff141e 100644 --- a/src/Adapters/MySqlAdapter.php +++ b/src/Adapters/MySqlAdapter.php @@ -12,6 +12,7 @@ public function format(string $column, string $interval): string 'minute' => '%Y-%m-%d %H:%i:00', 'hour' => '%Y-%m-%d %H:00', 'day' => '%Y-%m-%d', + 'week' => '%Y-%u', 'month' => '%Y-%m', 'year' => '%Y', default => throw new Error('Invalid interval.'), diff --git a/src/Adapters/PgsqlAdapter.php b/src/Adapters/PgsqlAdapter.php index 47e44b1..f0701f2 100644 --- a/src/Adapters/PgsqlAdapter.php +++ b/src/Adapters/PgsqlAdapter.php @@ -12,6 +12,7 @@ public function format(string $column, string $interval): string 'minute' => 'YYYY-MM-DD HH24:MI:00', 'hour' => 'YYYY-MM-DD HH24:00:00', 'day' => 'YYYY-MM-DD', + 'week' => 'YYYY-W', 'month' => 'YYYY-MM', 'year' => 'YYYY', default => throw new Error('Invalid interval.'), diff --git a/src/Adapters/SqliteAdapter.php b/src/Adapters/SqliteAdapter.php index 41e524c..3e17022 100644 --- a/src/Adapters/SqliteAdapter.php +++ b/src/Adapters/SqliteAdapter.php @@ -12,6 +12,7 @@ public function format(string $column, string $interval): string 'minute' => '%Y-%m-%d %H:%M:00', 'hour' => '%Y-%m-%d %H:00', 'day' => '%Y-%m-%d', + 'week' => '%Y-%W', 'month' => '%Y-%m', 'year' => '%Y', default => throw new Error('Invalid interval.'), diff --git a/src/Trend.php b/src/Trend.php index 02fb3a7..f4d9628 100755 --- a/src/Trend.php +++ b/src/Trend.php @@ -65,6 +65,11 @@ public function perDay(): self return $this->interval('day'); } + public function perWeek(): self + { + return $this->interval('week'); + } + public function perMonth(): self { return $this->interval('month'); @@ -172,6 +177,7 @@ protected function getCarbonDateFormat(): string 'minute' => 'Y-m-d H:i:00', 'hour' => 'Y-m-d H:00', 'day' => 'Y-m-d', + 'week' => 'Y-W', 'month' => 'Y-m', 'year' => 'Y', default => throw new Error('Invalid interval.'),