Skip to content
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

Can one object belongsTo more than one user ? #42

Open
jozefrebjak opened this issue Jan 9, 2023 · 1 comment
Open

Can one object belongsTo more than one user ? #42

jozefrebjak opened this issue Jan 9, 2023 · 1 comment

Comments

@jozefrebjak
Copy link

I have a table orders.

There is two columns disponent_id & salesman_id.

Both have foreign key to the users table id. If I don't overwrite a scheme, then it's used last one so only user paired to the salesman_id.

So I tried to overwrite schema like in #41. Now my relation to the users table looks like:

                [users] => Tatter\Schemas\Structures\Relation Object
                (
                    [table] => users
                    [type] => belongsTo
                    [singleton] => 
                    [pivots] => Array
                        (
                            [0] => Array
                                (
                                    [0] => orders
                                    [1] => salesman_id
                                    [2] => users
                                    [3] => id
                                )

                            [1] => Array
                                (
                                    [0] => orders
                                    [1] => disponent_id
                                    [2] => users
                                    [3] => id
                                )

                        )

                )

I think this is a bad design, but I need to pair two users from different groups because of internal settlement.

Thanks.

@MGatner
Copy link
Collaborator

MGatner commented Jan 10, 2023

This is currently a limitation of the structure, because it is based on table names. I believe there was a PR somewhere to allow aliases, which might provide a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants