Where 子句基于 Laravel 中的相关行数
Where clause based on number of related rows in Laravel
如何根据一对多关系中相关项的数量创建 where
子句?例如"select those Orders which have less than 5 Products"(假设Order-Product是一对多关系).
谢谢
使用 laravel 文档中的查询关系:link(查找 "Querying Relationship Existence")
示例(基于文档):
// Retrieve all posts that have less than three comments...
$posts = Post::has('comments', '<', 3)->get();
如何根据一对多关系中相关项的数量创建 where
子句?例如"select those Orders which have less than 5 Products"(假设Order-Product是一对多关系).
谢谢
使用 laravel 文档中的查询关系:link(查找 "Querying Relationship Existence")
示例(基于文档):
// Retrieve all posts that have less than three comments...
$posts = Post::has('comments', '<', 3)->get();