Skip to content

Conversation

staudenmeir
Copy link
Contributor

@staudenmeir staudenmeir commented Jan 3, 2019

loadMissing() doesn't work with duplicate relationship names:

$posts = Post::with('comments')->get();
$posts->loadMissing('comments.parent.parent');
                                     ^^^^^^

This is caused by the structure of the internal $path array:

// before
array:2 [
  "comments" => "comments"
  "parent" => "parent"
]

// now
array:3 [
  0 => array:1 [
    "comments" => "comments"
  ]
  1 => array:1 [
    "parent" => "parent"
  ]
  2 => array:1 [
    "parent" => "parent"
  ]
]

Fixes #27039.

@phh
Copy link
Contributor

phh commented Jan 3, 2019

Can confirm that this fixes my issue in #27039

@taylorotwell taylorotwell merged commit cec4317 into laravel:5.7 Jan 3, 2019
@staudenmeir staudenmeir deleted the load-missing branch January 3, 2019 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants