Skip to content

Commit

Permalink
Merge pull request #29129 from Mushr0000m/feature/morph-to-eager-load…
Browse files Browse the repository at this point in the history
…ing-performance

[5.8] Improve eager loading performance for MorphTo relation
  • Loading branch information
taylorotwell authored Jul 10, 2019
2 parents fccb701 + df2f36c commit 64917b5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ protected function getResultsByType($type)
(array) ($this->morphableEagerLoads[get_class($instance)] ?? [])
));

return $query->whereIn(
$whereIn = $this->whereInMethod($instance, $ownerKey);

return $query->{$whereIn}(
$instance->getTable().'.'.$ownerKey, $this->gatherKeysByType($type)
)->get();
}
Expand Down

0 comments on commit 64917b5

Please sign in to comment.