@@ -115,12 +115,6 @@ class Builder extends BaseBuilder
115
115
'>= ' => '$gte ' ,
116
116
];
117
117
118
- /**
119
- * Check if we need to return Collections instead of plain arrays (laravel >= 5.3 )
120
- * @var boolean
121
- */
122
- protected $ useCollections ;
123
-
124
118
/**
125
119
* @inheritdoc
126
120
*/
@@ -129,22 +123,6 @@ public function __construct(Connection $connection, Processor $processor)
129
123
$ this ->grammar = new Grammar ;
130
124
$ this ->connection = $ connection ;
131
125
$ this ->processor = $ processor ;
132
- $ this ->useCollections = $ this ->shouldUseCollections ();
133
- }
134
-
135
- /**
136
- * Returns true if Laravel or Lumen >= 5.3
137
- * @return bool
138
- */
139
- protected function shouldUseCollections ()
140
- {
141
- if (function_exists ('app ' )) {
142
- $ version = app ()->version ();
143
- $ version = filter_var (explode (') ' , $ version )[0 ], FILTER_SANITIZE_NUMBER_FLOAT , FILTER_FLAG_ALLOW_FRACTION ); // lumen
144
- return version_compare ($ version , '5.3 ' , '>= ' );
145
- }
146
-
147
- return true ;
148
126
}
149
127
150
128
/**
@@ -285,7 +263,7 @@ public function getFresh($columns = [])
285
263
'aggregate ' => $ totalResults
286
264
]
287
265
];
288
- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
266
+ return new Collection ($ results );
289
267
} elseif ($ function == 'count ' ) {
290
268
// Translate count into sum.
291
269
$ group ['aggregate ' ] = ['$sum ' => 1 ];
@@ -342,7 +320,7 @@ public function getFresh($columns = [])
342
320
$ results = iterator_to_array ($ this ->collection ->aggregate ($ pipeline , $ options ));
343
321
344
322
// Return results
345
- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
323
+ return new Collection ($ results );
346
324
} // Distinct query
347
325
elseif ($ this ->distinct ) {
348
326
// Return distinct results directly
@@ -355,7 +333,7 @@ public function getFresh($columns = [])
355
333
$ result = $ this ->collection ->distinct ($ column );
356
334
}
357
335
358
- return $ this -> useCollections ? new Collection ($ result ) : $ result ;
336
+ return new Collection ($ result );
359
337
} // Normal query
360
338
else {
361
339
$ columns = [];
@@ -404,7 +382,7 @@ public function getFresh($columns = [])
404
382
405
383
// Return results as an array with numeric keys
406
384
$ results = iterator_to_array ($ cursor , false );
407
- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
385
+ return new Collection ($ results );
408
386
}
409
387
}
410
388
@@ -659,7 +637,7 @@ public function pluck($column, $key = null)
659
637
}
660
638
661
639
$ p = Arr::pluck ($ results , $ column , $ key );
662
- return $ this -> useCollections ? new Collection ($ p ) : $ p ;
640
+ return new Collection ($ p );
663
641
}
664
642
665
643
/**
0 commit comments