Skip to content

Commit

Permalink
Merge pull request #27081 from staudenmeir/load-morph
Browse files Browse the repository at this point in the history
[5.7] Improve loadMorph()
  • Loading branch information
taylorotwell authored Jan 6, 2019
2 parents dfa5e3e + 8790908 commit 0e9b877
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Illuminate/Database/Eloquent/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,8 @@ public function loadMorph($relation, $relations)
->groupBy(function ($model) {
return get_class($model);
})
->filter(function ($models, $className) use ($relations) {
return Arr::has($relations, $className);
})
->each(function ($models, $className) use ($relations) {
$className::with($relations[$className])
->eagerLoadRelations($models->all());
static::make($models)->load($relations[$className] ?? []);
});

return $this;
Expand Down

0 comments on commit 0e9b877

Please sign in to comment.