Dear All,
I have 3 tables:
Customers
id
Relation_Types (can be Supplier or Customer)
id
Customer_Relations
id
customers_id (FK to Customers table)
partners_id (FK to Customers table)
relation_types_id (FK Relation_Types table)
So it means that a customer A can have many customers through Customer_Relations table and the same customer can have many suppliers through Customer_Relations table, and its customers and suppliers are also stored in Customers table
I would like to get all customers of a customer, and all suppliers of a customer, using relations and scopes.
But also, as a user belonging to a customer, I would like to get all my customers and all my suppliers.
Can you please help me how to implement those relations and scopes ?
Many thanks in advance for your help.
David