You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
I notice after installing Voyager that the User model has a belongsTo relationship with Roles, AND a belongsToMany relationship. The belongsTo has a database field and associated input field, but the belongsToMany does not have an input field (It has a pivot table). I have not been able to find any information anywhere on how to use the belongsToMany, specifically how to add a role or display the multiple roles, and what is the rationale for the simultaneous 1-1 and 1-many relationships.
I am very interested because 1) I can use multiple roles in my app and 2) I want to mimic what I think the paradigm is for something else in my app, but I need to fully understand it first.
Thank you!
Edit:
I would also like to add that I noticed an additional thing:
There are no corresponding relations in the other direction on Role. In the Laravel docs I understood them to say you would do a "belongsTo" pointing back to the model that "has" this model. Is that only if you want to be able to access the owner from the owned and unnecessary if you will not be accessing that way?
I'm sorry, my grasp of relationships is tenuous and I thought I understood how they work in Laravel, but what I see in Voyager challenges that understanding so I am trying to understand why it was done this way.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I notice after installing Voyager that the User model has a belongsTo relationship with Roles, AND a belongsToMany relationship. The belongsTo has a database field and associated input field, but the belongsToMany does not have an input field (It has a pivot table). I have not been able to find any information anywhere on how to use the belongsToMany, specifically how to add a role or display the multiple roles, and what is the rationale for the simultaneous 1-1 and 1-many relationships.
I am very interested because 1) I can use multiple roles in my app and 2) I want to mimic what I think the paradigm is for something else in my app, but I need to fully understand it first.
Thank you!
Edit:
I would also like to add that I noticed an additional thing:
There are no corresponding relations in the other direction on Role. In the Laravel docs I understood them to say you would do a "belongsTo" pointing back to the model that "has" this model. Is that only if you want to be able to access the owner from the owned and unnecessary if you will not be accessing that way?
I'm sorry, my grasp of relationships is tenuous and I thought I understood how they work in Laravel, but what I see in Voyager challenges that understanding so I am trying to understand why it was done this way.
Beta Was this translation helpful? Give feedback.
All reactions