-
Notifications
You must be signed in to change notification settings - Fork 92
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
Join type in nested sub-relations #104
Conversation
Documentation for join type in joinRelationship()
…ip callbacks: User::joinRelationship('posts.comments', [ 'posts' => function ($join) { $join->where('posts.published', true); }, 'comments' => function ($join) { $join->where('comments.approved', true); $join->joinType('leftPowerJoin'); } ]); Probable not the most effective way, but the least intrusive.
Hi @dmikam, thanks for the contribution. Would you mind adding some tests covering the new features you are adding? I don't feel comfortable merging this code without test coverage. |
Also, seems like your changes broke the existing tests, so definitely we need to adjust a few things here. |
# Conflicts: # tests/JoinRelationshipWithJoinTypesTest.php
Tests created. Broken tests fixed too. P.S.: Sorry for that bunch of commits - just was finding out how to work with Github actions and how to make them work in different branch. Also it took me some time to find out that the problem I had was due to that issue Nº105. |
Is it safe to use this PL? |
@luisdalmolin May we hope this PR to be included into the next release? |
@dmikam I'll review this again this week and likely include it. I may merge and apply some changes myself, mostly style, just FYI. |
Just tried the 3.2.0 release, but this functionality isn't there yet... Is there still a hope? Or should I just stick to my modified 2.65 version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be in v4 soon
Possibility to indicate join type for each relation in joinRelationship callbacks:
User::joinRelationship('posts.comments', [
'posts' => function ($join) {
$join->where('posts.published', true);
},
'comments' => function ($join) {
$join->where('comments.approved', true);
$join->left(); // you may also use $join->inner() or directly $join->joinType('leftPowerJoin')
}
]);
Probable not the most effective way, but the least intrusive.