Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,11 @@ public function newFromBuilder($attributes = array())
/**
* Create a collection of models from plain arrays.
*
* @param array $items
* @param string $connection
* @param array|\ArrayAccess $items
* @param string|null $connection
* @return \Illuminate\Database\Eloquent\Collection
*/
public static function hydrate(array $items, $connection = null)
public static function hydrate($items, $connection = null)
{
$collection = with($instance = new static)->newCollection();

Expand Down Expand Up @@ -1909,10 +1909,10 @@ protected function newBaseQueryBuilder()
/**
* Create a new Eloquent Collection instance.
*
* @param array $models
* @param array|\ArrayAccess $models
* @return \Illuminate\Database\Eloquent\Collection
*/
public function newCollection(array $models = array())
public function newCollection($models = array())
{
return new Collection($models);
}
Expand Down
17 changes: 8 additions & 9 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Closure;
use BadMethodCallException;
use InvalidArgumentException;
use Illuminate\Support\Collection;
use Illuminate\Pagination\Paginator;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Query\Grammars\Grammar;
Expand Down Expand Up @@ -1334,16 +1333,14 @@ public function pluck($column)
*/
public function first($columns = array('*'))
{
$results = $this->take(1)->get($columns);

return count($results) > 0 ? reset($results) : null;
return $this->take(1)->get($columns)->first();
}

/**
* Execute the query as a "select" statement.
*
* @param array $columns
* @return array|static[]
* @return \Illuminate\Support\Collection
*/
public function get($columns = array('*'))
{
Expand All @@ -1354,13 +1351,15 @@ public function get($columns = array('*'))
* Execute the query as a fresh "select" statement.
*
* @param array $columns
* @return array|static[]
* @return \Illuminate\Support\Collection
*/
public function getFresh($columns = array('*'))
{
if (is_null($this->columns)) $this->columns = $columns;

return $this->processor->processSelect($this, $this->runSelect());
$results = $this->processor->processSelect($this, $this->runSelect());

return collect($results);
}

/**
Expand Down Expand Up @@ -1502,7 +1501,7 @@ public function lists($column, $key = null)
{
$columns = $this->getListSelect($column, $key);

$results = new Collection($this->get($columns));
$results = $this->get($columns);

return $results->lists($columns[0], array_get($columns, 1));
}
Expand Down Expand Up @@ -1634,7 +1633,7 @@ public function aggregate($function, $columns = array('*'))

$previousColumns = $this->columns;

$results = $this->get($columns);
$results = $this->get($columns)->all();

// Once we have executed the query, we will reset the aggregate property so
// that more select queries can be executed against the database without
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function log($connection, $queue, $payload)
*/
public function all()
{
return $this->getTable()->orderBy('id', 'desc')->get();
return $this->getTable()->orderBy('id', 'desc')->get()->all();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ public function newQuery()
}

class EloquentModelHydrateRawStub extends Illuminate\Database\Eloquent\Model {
public static function hydrate(array $items, $connection = null) { return 'hydrated'; }
public static function hydrate($items, $connection = null) { return 'hydrated'; }
public function getConnection()
{
$mock = m::mock('Illuminate\Database\Connection');
Expand Down
6 changes: 3 additions & 3 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ public function testAggregateResetFollowedByGet()
$sum = $builder->sum('id');
$this->assertEquals(2, $sum);
$result = $builder->get();
$this->assertEquals(array(array('column1' => 'foo', 'column2' => 'bar')), $result);
$this->assertEquals(array(array('column1' => 'foo', 'column2' => 'bar')), $result->all());
}


Expand All @@ -807,7 +807,7 @@ public function testAggregateResetFollowedBySelectGet()
$count = $builder->count('column1');
$this->assertEquals(1, $count);
$result = $builder->select('column2', 'column3')->get();
$this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result);
$this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result->all());
}


Expand All @@ -821,7 +821,7 @@ public function testAggregateResetFollowedByGetWithColumns()
$count = $builder->count('column1');
$this->assertEquals(1, $count);
$result = $builder->get(array('column2', 'column3'));
$this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result);
$this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result->all());
}


Expand Down