繁体   English   中英

Laravel 4:如何在雄辩的ORM中结合

[英]Laravel 4 : How to combine where and with in eloquent ORM

我想要当前登录用户及其清单的json。 如何结合:: where和:: with?

这给了我当前登录的用户:

$user = User::where('user_id', '=', Auth::user()->user_id)->get();

这给了我所有用户和他们的清单:

$user = User::with('checklists')->get();

User::with()将返回一个雄辩的查询对象,因此

$user = User::with('checklists')
    ->where('user_id', '=', Auth::user()->user_id)
    ->get();

暂无
暂无

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

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