Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 8, 2019
1 parent 5bcee99 commit d72e3cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/Illuminate/Database/Eloquent/Relations/MorphTo.php
Expand Up @@ -42,7 +42,7 @@ class MorphTo extends BelongsTo
*
* @var array
*/
protected $typedEagerLoads = [];
protected $morphableEagerLoads = [];

/**
* Create a new morph to relationship instance.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Database/EloquentMorphEagerLoadingTest.php
@@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit d72e3cd

Please sign in to comment.