[10.x] Standardize withCount()
& withExists()
eager loading aggregates.
#42254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔴 There has been an attempt to add this functionality in #41914 but got reverted in #41943 due to a bug in the code. I figured I'd modify the function signatures to match the
with()
function and send it to10.x
instead.What does this PR do?
withCount()
&withExists()
aggregates.Why do we need this?
Before this PR
There are 3 different ways to pass parameters in
with...()
functions:is_array($relations) ? $relations : func_get_args()
).If we compare the
with()
,withCount()
&withExists
functions, this is what each of them currently support:with()
: 1, 2 & 3.withCount()
: 1 & 2.withExists()
: 1 (with only 1 relation 😞) & 2.The reason why I am writing this PR is because I ran into a situation where I assumed that since I was able to do it with one of these methods, why shouldn't I be able to do the same with any of the other 2 methods.
With this PR
The 3 functions mentioned above will support all 3 different ways to pass the params.