【发布时间】:2017-10-22 20:21:33
【问题描述】:
我需要在 Eloquent Laravel 中转换这个 SQL 查询
Select * from modulo where idmodulo not in
(select idmodulo from moduloperfil where moduloperfil.idperfil = 2)
号码2 是$request。
【问题讨论】:
-
你的
model..在哪里? -
你也可以使用whereNotIn。
-
模是我的模型
-
hooo 准备好了,这是我的解决方案 抱歉,请看 $result= \DB::table('modulo') ->whereNotIn('modulo.idmodulo',function ($query) use ($request ) { $query->select('moduloperfil.idmodulo')->from('moduloperfil') ->Where('moduloperfil.idperfil','=',$request->perfilselecionado); })->get()
-
那甚至不是
eloquent也没有使用model- 它只使用 Laravel 的查询生成器。在询问之前,您可以在the docs 阅读更多内容。谢谢。