Skip to content

[12.x] Add Support for Selective Relationship Autoloading in withRelationshipAutoloading #55673

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

Closed

Conversation

moe-mizrak
Copy link

@moe-mizrak moe-mizrak commented May 7, 2025

This PR adds support for selective column loading in withRelationshipAutoloading, similar to how with('client:id,name') works.

Please refer to withRelationshipAutoloading

With this enhancement, you can now specify which columns to load for a relationship, improving query performance by only retrieving the necessary data.

For example:

$orders->withRelationshipAutoloading(['client:id,name']);

Note

Backward compatibility is preserved:
When no columns are specified for a relationship, all columns continue to load by default. Other relationships continue autoloading as expected without needing to be explicitly defined.

Copy link

github-actions bot commented May 7, 2025

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@moe-mizrak moe-mizrak changed the title Feat/add selective relation autoload [12.x] add selective relation autoload to withRelationshipAutoloading May 7, 2025
@moe-mizrak
Copy link
Author

📌 Note: Looks like working for now, I will check some edge cases and add more advance tests.

@moe-mizrak moe-mizrak changed the title [12.x] add selective relation autoload to withRelationshipAutoloading [12.x] Add Support for Selective Relationship Autoloading in withRelationshipAutoloading May 8, 2025
}
}

$this->loadMissingRelationshipChain($tuples);
Copy link
Author

Choose a reason for hiding this comment

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

todo: this part will be modified, can be improved overall

@moe-mizrak moe-mizrak closed this May 8, 2025
@moe-mizrak
Copy link
Author

Not sure if its worth the complexity it adds up, abondening for now.

@moe-mizrak moe-mizrak deleted the feat/add-selective-relation-autoload branch May 8, 2025 16:11
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.

1 participant