-
Notifications
You must be signed in to change notification settings - Fork 4
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
Inverse relationship #5
Comments
Hi @Agufi28, thanks for your issue! |
Hi, thank you for your answer. I'll give you an example: Model Children:
Model Parent:
I need to get both parents from within the child model. It would be something like this: public function parents(){
return $this->hasManyMerged(Parent::class, "id", ["id_mother","id_father"]);
} The currents state of the library lets me do the relation from the Parent class. It's something like: public function children(){
return $this->hasManyMerged(Child::class, ["id_mother","id_father"]);
} This is not the exact escenario where I need the relation because the real one is far too complicated to use as an example. But it's essentially the same. I need to get bot parents from within the child. Thank you very much! |
Hi @Agufi28, Ok, so for the example in the README the Maybe something like this: public function participants(): BelongsToMerged
{
return $this->belongsToMerged(User::class, ['sender_user_id', 'receiver_user_id']);
} If this is what you mean, then I think that this is a good addition to this package and I will add it when I find the time in the following weeks (hopefully not months). |
Hi @korridor, I'm using this thread because I think it's related to my issue:
I would like to know how I can get something like |
There is
Then I just added a
After doing this I was able to access the method For anyone else who is looking for a way to use this package for the inverse of a relationship. Until this feature is added to the package, hopefully this helps someone out with inverse relationships. Please note, I would've forked this branch and submitted a merge request to this repo, But I know this is just a workaround and there's a better way to do this. |
Hi, I was wondering if by any change you could add support for inverse relationships. Same functionality but from the other side of the relartion. Thanks!
The text was updated successfully, but these errors were encountered: