Skip to content
Permalink
Browse files

formatting

  • Loading branch information...
taylorotwell committed Jun 8, 2019
1 parent 5bcee99 commit d72e3cd5be14dba654837466564018403839a5e9
@@ -42,7 +42,7 @@ class MorphTo extends BelongsTo
*
* @var array
*/
protected $typedEagerLoads = [];
protected $morphableEagerLoads = [];
/**
* Create a new morph to relationship instance.
@@ -120,7 +120,7 @@ protected function getResultsByType($type)
->mergeConstraintsFrom($this->getQuery())
->with(array_merge(
$this->getQuery()->getEagerLoads(),
(array) ($this->typedEagerLoads[get_class($instance)] ?? [])
(array) ($this->morphableEagerLoads[get_class($instance)] ?? [])
));
return $query->whereIn(
@@ -269,11 +269,10 @@ public function getDictionary()
* @param array $with
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function withMorph(array $with)
public function morphWith(array $with)
{
$this->typedEagerLoads = array_merge(
$this->typedEagerLoads,
$with
$this->morphableEagerLoads = array_merge(
$this->morphableEagerLoads, $with
);
return $this;
@@ -1,6 +1,6 @@
<?php
namespace Illuminate\Tests\Integration\Database\EloquentMorphToLazyEagerLoadingTest;
namespace Illuminate\Tests\Integration\Database\EloquentMorphEagerLoadingTest;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Eloquent\Model;
@@ -50,7 +50,7 @@ public function test_with_morph_loading()
{
$comments = Comment::query()
->with(['commentable' => function (MorphTo $morphTo) {
$morphTo->withMorph([Post::class => ['user']]);
$morphTo->morphWith([Post::class => ['user']]);
}])
->get();
@@ -63,7 +63,7 @@ public function test_with_morph_loading_with_single_relation()
{
$comments = Comment::query()
->with(['commentable' => function (MorphTo $morphTo) {
$morphTo->withMorph([Post::class => 'user']);
$morphTo->morphWith([Post::class => 'user']);
}])
->get();

0 comments on commit d72e3cd

Please sign in to comment.
You can’t perform that action at this time.