Well you can take a look at hasManyThrough
Source: http://laravel.com/docs/5.1/eloquent-relationships#has-many-through
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've been thinking about a database schema problem for what feels like forever and am now seeking a more experienced brain to point me in a good direction.
I'd like to have three tables,
Users Organisations Roles
But have a many to many relationship between all three. That is ... A user can belong to many organisations, and have one or many roles within that user-organisation pair. (Developer & Designer for example), but not necessarily have the same exact roles with another organisation.
A pivot table seems great as an initial start as far as the user-organisation pair is concerned, but as soon as I try get a user-organisation-role going, things seem to fall apart.
Could someone please post some simplistic schema structure and potentially a model sample establishing the eloquent methods which will be used to make it work ?
Please or to participate in this conversation.