From 5b504adad0eb873b4e9d15ac40fce268118eecf3 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 27 Nov 2025 13:22:04 +0800 Subject: [PATCH] update --- app/Models/CourseSign.php | 4 +-- app/Models/CourseType.php | 10 +++++++ ..._is_count_genban_to_course_types_table.php | 29 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2025_11_27_100000_add_is_count_genban_to_course_types_table.php diff --git a/app/Models/CourseSign.php b/app/Models/CourseSign.php index eafe558..80e1b9f 100755 --- a/app/Models/CourseSign.php +++ b/app/Models/CourseSign.php @@ -212,9 +212,9 @@ class CourseSign extends SoftDeletesModel public static function genban($start_date, $end_date, $course_ids = null, $retList = false) { $courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids); - // 获取制定的课程id + // 获取需要统计跟班学员的课程 $genbanCourse = Course::whereHas('typeDetail', function ($query) { - $query->whereIn('id', [1, 3, 14]); + $query->whereIn('is_count_genban', 1); })->get(); $courseSigns = $courseSignsQuery->whereHas('user', function ($query) { diff --git a/app/Models/CourseType.php b/app/Models/CourseType.php index a0ebea1..25aaf67 100755 --- a/app/Models/CourseType.php +++ b/app/Models/CourseType.php @@ -8,6 +8,16 @@ class CourseType extends SoftDeletesModel { const START_DATE = '2020-01-01 00:00:00'; + protected $appends = ['is_count_genban_text']; + + /** + * 是否统计跟班学员数文字 + */ + public function getIsCountGenbanTextAttribute() + { + return ($this->attributes['is_count_genban'] ?? 1) == 1 ? '是' : '否'; + } + public function courses() { return $this->hasMany(Course::class, 'type', 'id'); diff --git a/database/migrations/2025_11_27_100000_add_is_count_genban_to_course_types_table.php b/database/migrations/2025_11_27_100000_add_is_count_genban_to_course_types_table.php new file mode 100644 index 0000000..c87c6e8 --- /dev/null +++ b/database/migrations/2025_11_27_100000_add_is_count_genban_to_course_types_table.php @@ -0,0 +1,29 @@ +tinyInteger('is_count_genban')->default(0)->nullable()->comment('是否统计跟班学员数 0否 1是'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('course_types', function (Blueprint $table) { + $table->dropColumn('is_count_genban'); + }); + } +}; +