作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !3092
@@ -64,8 +64,24 @@ class MonthProjectCount extends Command @@ -64,8 +64,24 @@ class MonthProjectCount extends Command
64 ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month')) 64 ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
65 ->orderBy('month', 'asc') 65 ->orderBy('month', 'asc')
66 ->groupBy('month')->get()->toArray(); 66 ->groupBy('month')->get()->toArray();
67 - foreach ($list as $v){  
68 - $data[] = $v->month; 67 + $data = [];
  68 + if (!empty($list)) {
  69 + // 提取已有月份
  70 + foreach ($list as $v) {
  71 + $data[] = $v->month;
  72 + }
  73 + // 生成连续月份
  74 + $startMonth = $data[0];
  75 + $endMonth = end($data);
  76 + $fullMonths = [];
  77 + $current = $startMonth;
  78 + while ($current <= $endMonth) {
  79 + $fullMonths[] = $current;
  80 + $current = date('Y-m', strtotime($current . ' +1 month'));
  81 + }
  82 + $data = $fullMonths;
  83 + } else {
  84 + $data = [];
69 } 85 }
70 $list = $this->fillMissingMonths($data); 86 $list = $this->fillMissingMonths($data);
71 foreach ($list as $v){ 87 foreach ($list as $v){