我有两个表:买家和订单。买家有很多订单。
我想要所有买家以及特定时间段内订单数和两列订单(价格、费用)的总和。我可以通过执行以下操作来获取计数,
Buyer::withCount([
'orders' => fn ($query) => $query
->where('created_at', '>=', $dateTo)
])
->get();
但是如何获得指定时间段的总和(->where('created_at', '>=', $dateTo))?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号