简体   繁体   English

Laravel:在另一个数据透视表中使用一个数据透视表 ID

[英]Laravel: Using One pivot table id in another pivot table

I'm working in a Laravel 7 project.我在 Laravel 7 项目中工作。 I've implemented my table structure as below:我已经实现了我的表结构如下:

Programs and Sections many-to-many多对多的程序和部分

progarms 节目
program_id
section_id
sections 部分
name
program_section 程序段
program_id section_id

Teachers and Subjects many-to-many教师和科目多对多

teachers 老师
name email designation
subjects 科目
name
subject_teacher 学科老师
subject_id teacher_id

Now, what i want is to use the program_section (pivot) id inside subject_teacher pivot table, so that i can insert the program_section_id in subject_teacher table and get the program/section of specific teacher/subject.现在,我想要的是在subject_teacher数据透视表中使用program_section (pivot) id ,以便我可以在subject_teacher表中插入program_section_id并获取特定教师/科目的程序/部分。

Any idea how to do this using Laravel Eloquent ?知道如何使用Laravel Eloquent做到这Laravel Eloquent吗?

您可以在 Laravel 上使用多对多关系,请尝试阅读此内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM