laravel - A many to many relationship -
i've read docs on relationships , have few questions.
i have user , role table. relationship many many. user has many roles , role can belong many users. have set pivot table , have used belongstomany in each model. surely user hasmany roles , role belongstomany users.
but when use hasmany, queries not work expected. wording thing , both should belongstomany?
i wanted know defining relationship on each model - need or can defined on users?
the hasmany
relationship defining 1 many relationships , why break queries.
i can see why thinking along lines of user having many roles, english user belongs many roles , role belongs many users.
you don't need define relationship on both models if going query 1 model , it's relationship. can definitively never need query relationship on roles?
Comments
Post a Comment