Skip to content

Commit fe278ac

Browse files
authored
Support laravel 5.3
New Laravel queries always return collection. this is a backward compatible enhancement as Collections can be used as Arrays!
1 parent 78a5a05 commit fe278ac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function find($id, $columns = [])
146146
* Execute the query as a "select" statement.
147147
*
148148
* @param array $columns
149-
* @return array|static[]
149+
* @return array|static[]|Collection
150150
*/
151151
public function get($columns = [])
152152
{
@@ -157,7 +157,7 @@ public function get($columns = [])
157157
* Execute the query as a fresh "select" statement.
158158
*
159159
* @param array $columns
160-
* @return array|static[]
160+
* @return array|static[]|Collection
161161
*/
162162
public function getFresh($columns = [])
163163
{
@@ -259,7 +259,7 @@ public function getFresh($columns = [])
259259
$results = iterator_to_array($this->collection->aggregate($pipeline, $options));
260260

261261
// Return results
262-
return $results;
262+
return new Collection($results);
263263
}
264264

265265
// Distinct query
@@ -274,7 +274,7 @@ public function getFresh($columns = [])
274274
$result = $this->collection->distinct($column);
275275
}
276276

277-
return $result;
277+
return new Collection($result);
278278
}
279279

280280
// Normal query
@@ -317,7 +317,7 @@ public function getFresh($columns = [])
317317
$cursor = $this->collection->find($wheres, $options);
318318

319319
// Return results as an array with numeric keys
320-
return iterator_to_array($cursor, false);
320+
return new Collection(iterator_to_array($cursor, false));
321321
}
322322
}
323323

0 commit comments

Comments
 (0)