belongsTo on pivot table #49710
Unanswered
caiokawasaki
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Since a user has just one tenant, should the users table have a tenent_id? |
Beta Was this translation helpful? Give feedback.
2 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.
-
Yesterday I spent a few hours trying to resolve this, I ended up with a solution but I didn't really like it.
I started developing a multi-tenancy application and came across an issue when resolving user relations.
Each user can only belong to one
Tenant
, when he creates his account he is automatically attached to theTenant
related to the domain. When any user is loaded,Tenant
is automatically loaded so that the system can know the user's role, the only issue is that I couldn't bring in just oneTenant
, I need to bring them all in and then filter.These are my models:
My pivot class:
My solution was the following:
I would like to do something similar to this:
Is this possible?
Edit
I achieved something similar to what I want with the following relationship:
However, this way I cannot access the other columns of the pivot table.
Beta Was this translation helpful? Give feedback.
All reactions