Skip to content

Bucket grammars

countByInterval() groups in SQL, which differs per database. For a driver other than SQLite, MySQL, MariaDB or Postgres, implement BucketGrammar and register it. The Querying\Grammars\Concerns\ConvertsByOffset trait handles timezones, so a new grammar only implements truncate() and shift().

use CyrildeWit\EloquentViewable\Querying\Grammars\GrammarRegistry;
$this->app->afterResolving(GrammarRegistry::class, function (GrammarRegistry $grammars): void {
$grammars->register('sqlsrv', \App\Grammars\SqlServerBucketGrammar::class);
});