统计汇总技巧laravel
订单汇总
//第一种
Order::with()->withCount([
"order_item"=>function($query){
$query->select(DB::raw("(SUM(num)-SUM(use_num)) as counts"));
}])
//第二种
Order::with()->withCount([
"order_item"=>function($query){
$query->select(DB::raw("(SUM(num-use_num))"));
}])
统计汇总技巧laravel最先出现在Python成神之路。
共有 0 条评论