From 20b0c6e19b635466f776502b3f1260c7c51b04ae Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 29 Oct 2020 16:38:27 -0500 Subject: [PATCH] wrap directly through query --- .../Database/Eloquent/Concerns/QueriesRelationships.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php index d2589c46bf45..4a3930932bca 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php @@ -382,7 +382,7 @@ public function withAggregate($relations, $column, $function = null) $relation = $this->getRelationWithoutConstraints($name); $expression = $function - ? sprintf('%s(%s)', $function, $this->getGrammar()->wrap($column)) + ? sprintf('%s(%s)', $function, $this->getQuery()->getGrammar()->wrap($column)) : $column; // Here, we will grab the relationship sub-query and prepare to add it to the main query