File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 11
11
use MongoDB \Laravel \Collection ;
12
12
use MongoDB \Laravel \Helpers \QueriesRelationships ;
13
13
use MongoDB \Laravel \Internal \FindAndModifyCommandSubscriber ;
14
+ use MongoDB \Laravel \Query \AggregationBuilder ;
14
15
use MongoDB \Model \BSONDocument ;
15
16
use MongoDB \Operation \FindOneAndUpdate ;
16
17
@@ -57,15 +58,15 @@ class Builder extends EloquentBuilder
57
58
];
58
59
59
60
/**
60
- * @return ($function === null ? PipelineBuilder : self)
61
+ * @return ($function is null ? AggregationBuilder : self)
61
62
*
62
63
* @inheritdoc
63
64
*/
64
65
public function aggregate ($ function = null , $ columns = ['* ' ])
65
66
{
66
67
$ result = $ this ->toBase ()->aggregate ($ function , $ columns );
67
68
68
- return $ result ?? $ this ;
69
+ return $ result ?: $ this ;
69
70
}
70
71
71
72
/** @inheritdoc */
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ private function getAggregationBuilder(): AggregationBuilder
301
301
// Distinct query
302
302
if ($ this ->distinct ) {
303
303
// Return distinct results directly
304
- $ column = $ columns [0 ] ?? '_id ' ;
304
+ $ column = $ this -> columns [0 ] ?? '_id ' ;
305
305
306
306
$ agg ->group (
307
307
_id: \MongoDB \Builder \Expression::fieldPath ($ column ),
@@ -596,7 +596,7 @@ public function generateCacheKey()
596
596
return md5 (serialize (array_values ($ key )));
597
597
}
598
598
599
- /** @return ($function === null ? PipelineBuilder : self ) */
599
+ /** @return ($function is null ? AggregationBuilder : mixed ) */
600
600
public function aggregate ($ function = null , $ columns = [])
601
601
{
602
602
if ($ function === null ) {
You can’t perform that action at this time.
0 commit comments