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
Problem Defining a Special Relation #37
Comments
Please post the migrations of all the tables involved. |
@staudenmeir Just added the important parts of the migrations to the first post. Hope I didn't forget anything. The crucial part although is that there is a join required to get the |
Which one should be the parent model (where the relationship is defined)? |
@staudenmeir The |
In your What would the raw SQL query look like? |
An instance of I am not exactly sure how the query would look like to be honest. SELECT
customer_services.*
FROM
customer_services
JOIN service_jobs ON customer_services.service_id = service_jobs.service_id
JOIN jobs ON jobs.id = service_jobs.job_id
WHERE customer_services.service_id = service_jobs.service_id
AND customer_services.customer_id = jobs.customer_id
AND service_jobs.id = ? |
I don't see a way to define a relationship for this query. What makes this case so complicated is the fact that multiple constraints reference the parent table |
This is probably not the best place for my question but it was the closest to the topic I could think of. So I hope there will be some hints however.
Is there any possibility to define the following call as a relation?
I have so far not been able to figure it out, because it's some kind of hybrid between
belongsToThrough
and a belongsTo relation with composite keys. I also use Compoships.Thanks to your package I could at least already define the customer relation:
I would really like to benefit from the built-in query reduction, eager loading etc. that a relation would provide.
Here the database migrations:
The text was updated successfully, but these errors were encountered: