【发布时间】:2019-07-25 19:53:34
【问题描述】:
我需要嵌套关系集合的总和。当我尝试此代码时,找不到该字段。
return Offer::where("id", $offer_id)
->with(['rooms.products' => function($sql) use ($product_id) {
$sql->where('product_id', $product_id);
}]
)->sum("value");
值字段存在于 rooms.products 表中。
提前致谢
【问题讨论】:
-
你能用
get显示那个查询的结果吗?
标签: laravel eloquent nested relationship