Replies: 1 comment 3 replies
-
belongs to and has one can be used for the same thing. So hasOneThrough is usable for your case even if it is not named according to what you want. Can you please give arguments against the above? Maybe I am wrong. |
Beta Was this translation helpful? Give feedback.
3 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I recently needed to create a through relationship for this simple structure:
I wanted to define a relationship between Document and User.
I expected a
belongsToThrough
relationship, but I see there is not one available.It was discussed in #6161 but it didn't end up being implemented.
The best relationship available for this use case is
HasOneThrough
but it is defined backwards.It could be used to link User to a Document, assuming we know that both are 1 - 1 relationships (not the case here).
This problem was already noted in #42114, that also includes a viable solution to reach the desired result: just manually define the key constraints, reversing them from their defaults. In my case, this is:
Given the realization that a proper belongsToThrough relationship can be implemented without much effort reusing the HasOneThrough existing relationship, is there interest in implementing it?
Am I missing something, and this is not a fully viable solution?
I can submit a PR but given how the previous issues were closed I'm not sure there in interest or desire in it.
Beta Was this translation helpful? Give feedback.
All reactions