0
I am trying to create a relationship with the tables of my database using Windows, but with a certain difficulty in logic.
I have the tables; content, client and user
A user may have several client and a client may have several user, for this I created the relationship ManyToMany. (table client_user with the fields user_id and client_id), so far so good, I was able to do the relationship normally and now I can know which clients belong to which user.
Only I need now, select the contents of client which affect this user, how would I do that?
I thought of creating a pivot table (also) for content and client but how would I make this selection?
I want to get the contents which belong to the client that the user...
Look at the example of the database
Do you make use of the Eloquent ORM of the Standard? Have the relationship of models created?
– Jao Assy
I saw that there is one more Manytomany table in the client-content relationship. A client can have several contacts?
– lstonon
@Lucastonon.
– RFL
It doesn’t make much sense to have a pivot table in the relationship between client and content, because each content can only be from one client, so content loads the client key. On the issue of access to related data, have you tried using the relationship hasManyThrough? see the Laravel documentation for an example: https://laravel.com/docs/5.2/eloquent-relationships#has-Many-through
– lstonon