0
我有一张名为'templates'和'details'的表格,它具有关系模板,在我的模型中有很多细节。Laravel 5.2选择相关计数数据的位置
我创建一个带有过滤器编号或详细信息的列表模板表,当我向过滤器框输入5时,表中只显示具有5个细节的模板。
该怎么办?
这是我的表结构:
模板
ID |名称|宽度|身高
1 | A-5 | 112 | 100
2 | A-4 | 225 | 200个
细节
template_id | x | y
1 | 10 | 10
1 | 20 | 10
2 | 10 | 10
2 | 20 | 10
$templates = Template::whereHas('details', function($detail) {
$detail->selectRaw('count(id) as aduh')->whereRaw('count(id) = 100')->groupBy('id');
});
Is * details *您的表格中有一列吗?你可以添加你的表格结构和你期望得到的结果吗? – TheFallen