relations with combined queries #46330
Unanswered
CrisGuzmanS
asked this question in
Q&A
Replies: 1 comment
-
Did you try something like this?? Organization::whereHas('publications.persons', function($query){
//...
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! ✋ i am not sure if this is the correct place to put this problem, i want to tell you about it to know if you have an approach.
I have this 3 models:
The Organization has a many to many relation with Publication (through organization__publication table).
The Person has a many to many relation with Publication (through person__publication table).
The Organization has many to many relation with Person (through organization__person table).
In my Organization model i have my relation between Organization and Publication:
I want to get deep publications of the organization (the organization publications and the person publication that belongs to the organization). This is why i implemented this method:
as you see i achieved what i want. The problem is when i want to do this:
as you can see in my deepPublications method i create a new query, i was thinking to create an scope method (scopeDeepPublications), but i am still not achieving what i want. Do you know any approach to do this?
Beta Was this translation helpful? Give feedback.
All reactions