@@ -120,12 +120,6 @@ class Builder extends BaseBuilder
120120 '>= ' => '$gte ' ,
121121 ];
122122
123- /**
124- * Check if we need to return Collections instead of plain arrays (laravel >= 5.3 )
125- * @var boolean
126- */
127- protected $ useCollections ;
128-
129123 /**
130124 * @inheritdoc
131125 */
@@ -134,22 +128,6 @@ public function __construct(Connection $connection, Processor $processor)
134128 $ this ->grammar = new Grammar ;
135129 $ this ->connection = $ connection ;
136130 $ this ->processor = $ processor ;
137- $ this ->useCollections = $ this ->shouldUseCollections ();
138- }
139-
140- /**
141- * Returns true if Laravel or Lumen >= 5.3
142- * @return bool
143- */
144- protected function shouldUseCollections ()
145- {
146- if (function_exists ('app ' )) {
147- $ version = app ()->version ();
148- $ version = filter_var (explode (') ' , $ version )[0 ], FILTER_SANITIZE_NUMBER_FLOAT , FILTER_FLAG_ALLOW_FRACTION ); // lumen
149- return version_compare ($ version , '5.3 ' , '>= ' );
150- }
151-
152- return true ;
153131 }
154132
155133 /**
@@ -303,7 +281,7 @@ public function getFresh($columns = [], $returnLazy = false)
303281 'aggregate ' => $ totalResults
304282 ]
305283 ];
306- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
284+ return new Collection ($ results );
307285 } elseif ($ function == 'count ' ) {
308286 // Translate count into sum.
309287 $ group ['aggregate ' ] = ['$sum ' => 1 ];
@@ -360,7 +338,7 @@ public function getFresh($columns = [], $returnLazy = false)
360338 $ results = iterator_to_array ($ this ->collection ->aggregate ($ pipeline , $ options ));
361339
362340 // Return results
363- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
341+ return Collection ($ results );
364342 } // Distinct query
365343 elseif ($ this ->distinct ) {
366344 // Return distinct results directly
@@ -373,7 +351,7 @@ public function getFresh($columns = [], $returnLazy = false)
373351 $ result = $ this ->collection ->distinct ($ column );
374352 }
375353
376- return $ this -> useCollections ? new Collection ($ result ) : $ result ;
354+ return new Collection ($ result );
377355 } // Normal query
378356 else {
379357 $ columns = [];
@@ -430,7 +408,7 @@ public function getFresh($columns = [], $returnLazy = false)
430408
431409 // Return results as an array with numeric keys
432410 $ results = iterator_to_array ($ cursor , false );
433- return $ this -> useCollections ? new Collection ($ results ) : $ results ;
411+ return new Collection ($ results );
434412 }
435413 }
436414
@@ -685,7 +663,7 @@ public function pluck($column, $key = null)
685663 }
686664
687665 $ p = Arr::pluck ($ results , $ column , $ key );
688- return $ this -> useCollections ? new Collection ($ p ) : $ p ;
666+ return new Collection ($ p );
689667 }
690668
691669 /**
0 commit comments