嗨我有一些完整的想法如何在一个wherehas查询中使用select或者我是以错误的方式做的? 查询工作,但它没有选择。
$query = $query->whereHas('orderProducts', function($q){
$q->select(DB::raw('SUM(order_product.total) AS spent_total'));
$q->select(DB::raw('COUNT(order_product.box_id) as box_count'));
});
感谢。