Skip to content

Commit c24bf57

Browse files
Adds withoutEagerLoad function (#42641)
* Adds `withoutEagerLoad` function * Update Builder.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent dbad869 commit c24bf57

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,19 @@ public function setEagerLoads(array $eagerLoad)
15731573

15741574
return $this;
15751575
}
1576+
1577+
/**
1578+
* Indicate that the given relationships should not be eagerly loaded.
1579+
*
1580+
* @param array $relations
1581+
* @return $this
1582+
*/
1583+
public function withoutEagerLoad(array $relations)
1584+
{
1585+
$relations = array_diff(array_keys($this->model->getRelations()), $relations);
1586+
1587+
return $this->with($relations);
1588+
}
15761589

15771590
/**
15781591
* Flush the relationships being eagerly loaded.

0 commit comments

Comments
 (0)