【发布时间】:2017-07-26 03:17:24
【问题描述】:
我需要按部门过滤,例如where('departamento_id', '=', 1)。
表格:
membro_bancas
id
departamento_id
user_id
trabalhos
id
titulo
orientador_id (references id of membro_bancas)
coorientador_id (references id of membro_bancas)
我有这个代码:
$trabalho = Trabalho::with('membrobanca.departamento')
->with('coorientador')
->with('academico')
->get();
然后返回:
【问题讨论】:
-
尝试做 $trabalho = Trabalho::with('membrobanca.departamento') ->with('coorientador') ->with('academico') ->where('membrobanca.departamento.departamento_id ', '=' , 1) ->get();
-
顺便说一句,您要过滤哪个 ID?是在“membrobanca”还是在“departamento”?
-
有什么区别?因为我需要用你的 Academicos、membrobancas 和 coorientador 检索所有 Trabalhos,并按 departamento of membrobanca 过滤
-
如果是这种情况,那么您可以编写所有过滤器。所以,例子。 ->where('coorientador.departamento_id', '=', 1) ->where('membrobancas.departamento_id', '=', 1)
-
不,很遗憾。