【发布时间】:2020-04-02 19:21:27
【问题描述】:
您好,我是 laravel 新手,我想实现以下目标
- 我在下面有 2 个表,即 table1 和 table2
table1 = students[{id="1", firstname="john", lastname="doe"},
{id="2", firstname="james", lastname="bond"}]
table2 = subjects[{id="1", code="math101", subject="math", description="Introduction", units="3"},
id="2", code="eng101", subject="English", description="introduction", units="3"]
- 现在在 laravel 控制器中我想实现以下目标
public function create(){
//lets assume that i received these id's from the routes
// i want to use this id's to filter the data i want to add to the table3
id = 2 //students
id = 1 //subjects
table3 = enroll[{id="1" student_id="2", firstname="john", lastname="doe", code="math101", subject="math", description="Introduction", units="3"}]
我想合并这两个表中的数据并将其保存到新表中,这样它就会像上面的表 3 中那样
如何在 laravel 控制器中实现这一点
提前致谢
【问题讨论】: