Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed May 29, 2024
1 parent 1660734 commit 425fc90
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 425fc90

Please sign in to comment.