[9.x] Make whereBelongsTo accept Collection#41733
Conversation
e720511 to
605ec9e
Compare
|
Could somebody explain or point to the docs, why whereIn accepts a flag |
|
@a-bashtannik It allows you to make the distinction between adding |
|
@erikgaal argghh so simple true, thanks! |
|
@erikgaal did you give any thoughts to just baking this functionality into |
No, I haven't. Seems logical to support both a single |
|
@erikgaal yeah I think it's fine to bake this behavior into the existing method. |
whereBelongsToOneOf Eloquent builder methodwhereBelongsTo accept Collection
4268af6 to
d260892
Compare
d260892 to
3fef433
Compare
|
@taylorotwell Done! |
|
Hi @erikgaal would it be possible for empty collections to be passed? Id expect it to work the same as if i pass [] to whereIn(), no records would be returned, this would be handy to avoid some conditional checks. |
Hi there!
Extending upon #38927, I'm submitting this PR that allows you to retrieve records using a collection of related records.
Previously, if you wanted to retrieve, for example, all Posts that belong to one of multiple Categories, you would need to perform the following query:
Same as in the aforementioned PR, you would need to know the key names when building and maintain these if they change. This PR adds support for Collections passed to the
whereBelongsTomethod: