diff --git a/app/Http/Controllers/Admin/CalendarsController.php b/app/Http/Controllers/Admin/CalendarsController.php index ba19e6b..d9170d0 100644 --- a/app/Http/Controllers/Admin/CalendarsController.php +++ b/app/Http/Controllers/Admin/CalendarsController.php @@ -75,7 +75,21 @@ class CalendarsController extends BaseController $query->where('start_time', 'like', $year . '%'); } })->where('is_count_days', 1)->sum('days'); - return $this->success(compact('list', 'monthDayCalendar', 'yearDayCalendar')); + // 本月开课场次 + $monthCourseCount = Calendar::where(function ($query) use ($all) { + if (isset($all['month'])) { + $query->where('start_time', 'like', $all['month'] . '%'); + } + })->count(); + // 本年开课场次 + $yearCourseCount = Calendar::where(function ($query) use ($all) { + if (isset($all['month'])) { + // 获取$all['month']的年份部分 + $year = date('Y', strtotime($all['month'])); + $query->where('start_time', 'like', $year . '%'); + } + })->count(); + return $this->success(compact('list', 'monthDayCalendar', 'yearDayCalendar', 'monthCourseCount', 'yearCourseCount')); } /**