From 8c2e00f23ae5a80d112e37481891828fa090b5fb Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 27 Nov 2025 16:35:58 +0800 Subject: [PATCH] update --- .../Controllers/Admin/CalendarsController.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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')); } /**