Many to Many relationship

Posted 2 years ago by tjkalinowski

Lets assume, that we have Users and Types, and pivot type_user tables ready. We have done models User and Type relationship.

  • How to display all records in Types table one by one, and its Users assigned?
  • How to display all records in Types tables, which is of type 1 or type 2
  • Can you give me good source of example codes?
id name
1 Name1
2 Name2

id name
1 Type1
2 Type2

id name_id type_id
1 1 1
2 1 2
3 2 1
4 2 2

How to display example screen :
Names | Types
Name1 | Type1 and Type2
Name2 | Type1 and Type2

Please sign in or create an account to participate in this conversation.