Search code examples
phpdatabaselaravelrelational

name this laravel5.4 eloquent relationship in three tables


I studied eloquent relationships in laravel, i love to use them but today am confuse about relation the following three tables has. I have a relation between three tables like:

1) companies   {id, company_name}
2) screens     {id, screen_name}
3) company_screen   {id, company_id, screen_id, connected[yes/no] }

what type of relation is this in laravel? how can i fetch screens which are connected(yes), for a company?


Solution

  • after posting my question i read many to many relation in https://laravel.com/docs/5.4/eloquent-relationships#updating-many-to-many-relationships it's just many to many relation with and extra column in pivot table.

    thanks