Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我有一个Userhas many Comments,但我只想查询Commentis status 1 。我如何在 Laravel 中使用 Eloquent ORM 来做到这一点?谢谢
User
Comments
Comment
使用类似的东西
$user->comments()->where('status', 1)->get();
通过在注释后添加括号,您将收到一个 QueryBuilder 实例而不是结果集合。