From 0783f4ca09bec7e14abc87962dff8241c42bfaaa Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Mon, 24 Nov 2025 13:23:55 +0800 Subject: [PATCH] update --- app/Http/Controllers/Admin/OtherController.php | 4 ++-- app/Models/CourseSign.php | 9 +-------- app/Models/HistoryCourse.php | 5 +++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index 26f117e..ad1f09a 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -277,10 +277,10 @@ class OtherController extends CommonController // 开始结束日期的筛选。or查询 $query->whereBetween('start_date', [$start_date, $end_date]) ->orWhereBetween('end_date', [$start_date, $end_date]); - })->get(); + })->where('type', $course_type_id)->get(); foreach ($historyCourses as $historyCourse) { $courseTypesSum[] = [ - 'course_type' => $historyCourse->course_type, + 'course_type' => $historyCourse->typeDetail->name, // 培养人数 'course_type_signs_pass' => $historyCourse->course_type_signs_pass, // 去重培养人数 diff --git a/app/Models/CourseSign.php b/app/Models/CourseSign.php index d7244bd..9998575 100755 --- a/app/Models/CourseSign.php +++ b/app/Models/CourseSign.php @@ -179,14 +179,7 @@ class CourseSign extends SoftDeletesModel return $list; } else { // 返回统计数据 - $baseTotal = $list->count(); - // 历史数据 - $historyTotal = HistoryCourse::where(function ($query) use ($start_date, $end_date) { - // 开始结束日期的筛选。or查询 - $query->whereBetween('start_date', [$start_date, $end_date]) - ->orWhereBetween('end_date', [$start_date, $end_date]); - })->where('type', request('course_type_id'))->sum('course_type_signs_pass_unique'); - return $baseTotal + $historyTotal; + return $list->count(); } } diff --git a/app/Models/HistoryCourse.php b/app/Models/HistoryCourse.php index d0ac3e2..4eb14bf 100644 --- a/app/Models/HistoryCourse.php +++ b/app/Models/HistoryCourse.php @@ -4,5 +4,10 @@ namespace App\Models; class HistoryCourse extends SoftDeletesModel { + + public function typeDetail() + { + return $this->hasOne(CourseType::class, 'id', 'type'); + } }