Skip to content

Conversation

staudenmeir
Copy link
Contributor

Prevents unnecessary queries when lazy loading empty relationships:

(new Post(['user_id' => null]))->user; // null
(new User)->posts;                     // []

MorphTo::getResults() is now handled by BelongsTo::getResults() (#8586).

This does not apply to custom relationship queries like (new User)->posts()->get().

I don't think we need additional tests for this. There are plenty of tests that verify relationship queries.

Fixes #25214, #24241, #20616 and laravel/ideas#748.

Copy link
Member

@brunogaspar brunogaspar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one!

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.

4 participants