Skip to content

Conversation

angus-mcritchie
Copy link
Contributor

This pull request attempts to solve the same issue as this PR #54554 but was closed after @taylorotwell , the legend himself, said in this comment #54554 (comment)

Could we not re-use the logic we use for this elsewhere? It feels odd to have to recreate this logic here.

So this PR attempts to do just that.

As a refresher, this PR aims to make loadMissing consistent with load and with Eloquent methods, as I'm sure I'm not the only developer who has tried the following code and found out the hard way it doesn't work as expected.

$posts->loadMissing([
    'comments' => [
        'user' => fn($query) => $query->select(['id', 'name']),
        'relatedComments'
    ],
    'relatedPosts'
]);

Credit to @lioneaglesolutions for some of the tests 👍

@taylorotwell taylorotwell merged commit a46c765 into laravel:12.x Aug 27, 2025
59 of 60 checks passed
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.

2 participants