【发布时间】:2018-12-08 01:07:01
【问题描述】:
我正在尝试设置考试时间表模块, 这是表结构:-
id
title
start_date
end_date
class_id
subject_id
date(for each subject_id)
现在问题是 class_id 作为“id”存在于教室表中,我需要从中获取它的名称,该名称在表中作为“title”。同样,对于在主题表中作为“id”存在的subject_id,在表中作为“title”的名称。一旦我得到这些,数据库表将如下所示:-
id title start_date end_date class_id subject_id date
1 test some_date some_date 1 1 date
1 test some_date some_date 1 2 date
1 test some_date some_date 1 3 date
1 test some_date some_date 1 4 date
如何设置我的控制器与关系,请帮助!
【问题讨论】:
-
首先阅读Eloquent relationships 上的文档。有很多例子。如果您有任何具体问题,请回来。
-
我已经问了我的具体问题@fubar
-
您可以查看表格之间的文字以获取问题,还有没有更好的方法?