@@ -115,12 +115,6 @@ class Builder extends BaseBuilder
115115 '>= ' => '$gte ' ,
116116 ];
117117
118- /**
119- * Check if we need to return Collections instead of plain arrays (laravel >= 5.3 )
120- * @var boolean
121- */
122- protected $ useCollections ;
123-
124118 /**
125119 * @inheritdoc
126120 */
@@ -129,22 +123,6 @@ public function __construct(Connection $connection, Processor $processor)
129123 $ this ->grammar = new Grammar ;
130124 $ this ->connection = $ connection ;
131125 $ 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 ;
148126 }
149127
150128 /**
@@ -285,7 +263,7 @@ public function getFresh($columns = [])
285263 'aggregate ' => $ totalResults
286264 ]
287265 ];
288- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
266+ return new Collection ($ results );
289267 } elseif ($ function == 'count ' ) {
290268 // Translate count into sum.
291269 $ group ['aggregate ' ] = ['$sum ' => 1 ];
@@ -342,7 +320,7 @@ public function getFresh($columns = [])
342320 $ results = iterator_to_array ($ this ->collection ->aggregate ($ pipeline , $ options ));
343321
344322 // Return results
345- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
323+ return new Collection ($ results );
346324 } // Distinct query
347325 elseif ($ this ->distinct ) {
348326 // Return distinct results directly
@@ -355,7 +333,7 @@ public function getFresh($columns = [])
355333 $ result = $ this ->collection ->distinct ($ column );
356334 }
357335
358- return $ this -> useCollections ? new Collection ($ result ) : $ result ;
336+ return new Collection ($ result );
359337 } // Normal query
360338 else {
361339 $ columns = [];
@@ -404,7 +382,7 @@ public function getFresh($columns = [])
404382
405383 // Return results as an array with numeric keys
406384 $ results = iterator_to_array ($ cursor , false );
407- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
385+ return new Collection ($ results );
408386 }
409387 }
410388
@@ -659,7 +637,7 @@ public function pluck($column, $key = null)
659637 }
660638
661639 $ p = Arr::pluck ($ results , $ column , $ key );
662- return $ this -> useCollections ? new Collection ($ p ) : $ p ;
640+ return new Collection ($ p );
663641 }
664642
665643 /**
0 commit comments