Relationship between 3 Models in Laravel
I’m trying to make a relation between 3 Models in Laravel 5.6
Here are my tables
departments
- id
- name
subjects
- id
- name
teachers
- id
- name
teach
- id_teacher
- id_department
- id_subject
The relationship between all tables is many to many
(Teacher can teach many subjects in many department, department belongs to many subject, and subject belongs to many department)
I don’t know how to make these relationships inside The Teacher, Department and Subject Models cause there are many of them in Laravel documentation.
from Laravel Questions and Answers https://laravelquestions.com/php/relationship-between-3-models-in-laravel/
via Lzo Media
No comments:
Post a Comment