-
Notifications
You must be signed in to change notification settings - Fork 1
Group By
Gilberto Junior edited this page Nov 29, 2019
·
3 revisions
This method agroups rows to summarize.
public function groupBy(string $column1, string $column2, ...): self;
public function groupBy(array $columns): self;
public function groupBy(string $sql): self;
PHP's way:
$repository->groupBy('user_id', 1);
SQL's Representation:
GROUP BY
user_id, 1
PHP's way:
$repository->groupBy([
'brand_id',
'category_id',
]);
SQL's Representation:
GROUP BY
brand_id, category_id
PHP's way:
$repository->groupBy('customer_id, CAST(created_at AS DATE)');
SQL's Representation:
GROUP BY
customer_id, CAST(created_at AS DATE)
by c0dehappy