From 425fc90ade3b5454be81318c0501578e831959a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Wed, 29 May 2024 12:17:54 +0200 Subject: [PATCH] fix --- src/Fields/Relation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Fields/Relation.php b/src/Fields/Relation.php index 783f9c9d..e99be184 100644 --- a/src/Fields/Relation.php +++ b/src/Fields/Relation.php @@ -485,7 +485,11 @@ public function resolveRelatableQuery(Request $request, Model $model): Builder public function aggregate(string $fn = 'count', string $column = '*'): static { $this->aggregateResolver = function (Request $request, Builder $query) use ($fn, $column): Builder { - $this->setModelAttribute(sprintf('%s_%s', $this->getRelationName(), $fn)); + $this->setModelAttribute(sprintf( + '%s_%s%s', $this->getRelationName(), + $fn, + $column === '*' ? '' : sprintf('_%s', $column) + )); $this->aggregated = true;