Skip to content

Commit

Permalink
Method load in Illuminate\Database\Eloquent\Collection should also (#…
Browse files Browse the repository at this point in the history
…22363)

use a newQueryWithoutRelationships to be aligned with the load method
in Illuminate\Database\Eloquent\Model
  • Loading branch information
salexi authored and taylorotwell committed Dec 11, 2017
1 parent ba8e205 commit 1a86cdb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function load($relations)
$relations = func_get_args();
}

$query = $this->first()->newQuery()->with($relations);
$query = $this->first()->newQueryWithoutRelationships()->with($relations);

$this->items = $query->eagerLoadRelations($this->items);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/DatabaseEloquentCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testLoadMethodEagerLoadsGivenRelationships()
$c = $this->getMockBuilder('Illuminate\Database\Eloquent\Collection')->setMethods(['first'])->setConstructorArgs([['foo']])->getMock();
$mockItem = m::mock('stdClass');
$c->expects($this->once())->method('first')->will($this->returnValue($mockItem));
$mockItem->shouldReceive('newQuery')->once()->andReturn($mockItem);
$mockItem->shouldReceive('newQueryWithoutRelationships')->once()->andReturn($mockItem);
$mockItem->shouldReceive('with')->with(['bar', 'baz'])->andReturn($mockItem);
$mockItem->shouldReceive('eagerLoadRelations')->once()->with(['foo'])->andReturn(['results']);
$c->load('bar', 'baz');
Expand Down

0 comments on commit 1a86cdb

Please sign in to comment.