diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index df4617e..5a5d2b5 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -222,7 +222,7 @@ class OtherController extends CommonController $course_type_id = $params['course_type_id']; $courses = $params['courses']; // 被投企业数 - // $list['course_signs_invested'] = CourseSign::yhInvested($start_date, $end_date, $courses->pluck('id')->toArray()); + $list['course_signs_invested'] = CourseSign::yhInvested($start_date, $end_date, $courses->pluck('id')->toArray()); // 报名人数 $list['course_signs_total'] = CourseSign::courseSignsTotal($start_date, $end_date, null, $courses->pluck('id')); // 审核通过人数 diff --git a/app/Http/Controllers/Mobile/UserController.php b/app/Http/Controllers/Mobile/UserController.php index f5d37a1..724518a 100755 --- a/app/Http/Controllers/Mobile/UserController.php +++ b/app/Http/Controllers/Mobile/UserController.php @@ -164,7 +164,7 @@ class UserController extends CommonController */ public function updateUser() { - $all = \request()->except(['id','mobile','openid']); + $all = \request()->except(['id', 'mobile', 'openid']); $model = User::find($this->getUserId()); if (isset($all['password'])) { // 判断旧密码是否正确 @@ -174,6 +174,8 @@ class UserController extends CommonController $model->password = Hash::make($all['password']); } if (isset($all['username']) && !empty($all['username'])) { + // 去除左右两边和中间的空格 + $all['username'] = str_replace(' ', '', trim($all['username'])); $all['name'] = $all['username']; } if (isset($all['name']) && !empty($all['name'])) { diff --git a/app/Models/CourseSign.php b/app/Models/CourseSign.php index 0f266ec..80e1b9f 100755 --- a/app/Models/CourseSign.php +++ b/app/Models/CourseSign.php @@ -157,8 +157,7 @@ class CourseSign extends SoftDeletesModel public static function yhInvested($start_date = null, $end_date = null, $course_ids = null, $retList = false) { // 判断是否使用默认时间 - $isDefaultDate = empty($start_date) || $start_date == CourseType::START_DATE || empty($course_ids); - dd(empty($start_date) , $start_date == CourseType::START_DATE , empty($course_ids)); + $isDefaultDate = (empty($start_date) || $start_date == CourseType::START_DATE) && empty($course_ids); // 获取学员ID列表 if ($isDefaultDate) { // 默认时间:获取所有学员,不限制课程 @@ -213,9 +212,14 @@ 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); + // 获取需要统计跟班学员的课程 + $genbanCourse = Course::whereHas('typeDetail', function ($query) { + $query->whereIn('is_count_genban', 1); + })->get(); + $courseSigns = $courseSignsQuery->whereHas('user', function ($query) { $query->where('from', 'like', '%跟班学员%'); - })->get(); + })->whereIn('course_id', $genbanCourse->pluck('id'))->get(); if ($retList) { return User::with('company')->whereIn('id', $courseSigns->pluck('user_id'))->get(); 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'); + }); + } +}; +