Commit a203a12d by Taylor Otwell

Merge pull request #799 from Jelle-S/develop

Eloquent - simplify eager loading
parents 81efdcf1 ac8bd082
...@@ -253,7 +253,27 @@ abstract class Model { ...@@ -253,7 +253,27 @@ abstract class Model {
*/ */
public function _with($includes) public function _with($includes)
{ {
$this->includes = (array) $includes; $includes = (array) $includes;
$all_includes = array();
foreach($includes as $include)
{
$nested = explode('.', $include);
$inc = array();
foreach($nested as $relation)
{
$inc[] = $relation;
$all_includes[] = implode('.', $inc);
}
}
//remove duplicates and reset the array keys.
$this->includes = array_values(array_unique($all_includes));
return $this; return $this;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment