NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
统计函数 ``` $result = Model::countStatus('status'); public static function countStatus($cat) { $result = Model::select(DB::raw('count(*) as '.$cat.'_count, '.$cat)) ->groupBy($cat) ->get(); $allCatArr = \Qiniu\json_decode($result); $allCat = array_sum(array_column($allCatArr, $cat.'_count')); $allCat1[$cat.'_count'] = $allCat; $allCat1[$cat] = "全部"; $allCatArr[] = $allCat1; // 将结果追加到数组 return $allCatArr; } ```