企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
统计函数 ``` $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; } ```