Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Fix loadMissing() with duplicate relation names #27040

Merged
merged 1 commit into from
Jan 3, 2019
Merged

[5.7] Fix loadMissing() with duplicate relation names #27040

merged 1 commit into from
Jan 3, 2019

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.

None yet

3 participants