From a22eb8cad75489a8c2752ae81ba4fd5f6c157d72 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Fri, 28 Nov 2025 15:13:39 +0800 Subject: [PATCH] update --- app/Http/Controllers/Admin/UserController.php | 49 +++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 4eed937..7d2ac42 100755 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -55,9 +55,11 @@ class UserController extends BaseController { $all = request()->all(); $list = $this->model->with(underlineToHump($all['show_relation'] ?? [])) - ->with(['courseSigns' => function ($query) use ($all) { - $query->where('status', 1)->with('course.teacher', 'course.typeDetail'); - }])->where(function ($query) use ($all) { + ->with([ + 'courseSigns' => function ($query) use ($all) { + $query->where('status', 1)->with('course.teacher', 'course.typeDetail'); + } + ])->where(function ($query) use ($all) { if (isset($all['keyword'])) { $query->whereHas('courses', function ($q) use ($all) { $q->where('name', 'like', '%' . $all['keyword'] . '%'); @@ -196,13 +198,22 @@ class UserController extends BaseController $start_date = $year . '-01-01'; $end_date = $year . '-12-31'; - $list = $this->model->with('appointments', 'companyIndustryDetail', - 'companyPositionDetail', 'companyAreaDetail', 'company') - ->with(['courseSigns' => function ($query) { - $query->with('course.typeDetail')->orderBy('fee_status', 'desc'); - }])->withCount(['appointments' => function ($query) { - $query->whereIn('status', [0, 1]); - }]); + $list = $this->model->with( + 'appointments', + 'companyIndustryDetail', + 'companyPositionDetail', + 'companyAreaDetail', + 'company' + ) + ->with([ + 'courseSigns' => function ($query) { + $query->with('course.typeDetail')->orderBy('fee_status', 'desc'); + } + ])->withCount([ + 'appointments' => function ($query) { + $query->whereIn('status', [0, 1]); + } + ]); // 是否被投企业 if (isset($all['is_yh_invested'])) { $list = $list->whereHas('company', function ($query) use ($all) { @@ -221,9 +232,16 @@ class UserController extends BaseController // 新数据 if (isset($all['company_tag'])) { $list = $list->whereHas('company', function ($query) use ($all) { - foreach (explode(',', $all['company_tag']) as $v) { - $query->orWhere('company_tag', 'like', '%' . $v . '%'); - } + $string = explode(',', $all['company_tag']); + $query->where(function ($q) use ($string) { + foreach ($string as $index => $v) { + if ($index === 0) { + $q->where('company_tag', 'like', '%' . trim($v) . '%'); + } else { + $q->orWhere('company_tag', 'like', '%' . trim($v) . '%'); + } + } + }); }); } @@ -522,7 +540,8 @@ class UserController extends BaseController } else { if (in_array($k, ['company_type', 'type'])) { $list[$key][$k] = str_replace('、', ',', $value[$v]); - $list[$key][$k] = str_replace(',', ',', $list[$key][$k]);; + $list[$key][$k] = str_replace(',', ',', $list[$key][$k]); + ; } else { $list[$key][$k] = $value[$v]; } @@ -673,7 +692,7 @@ class UserController extends BaseController if (isset($all['is_schoolmate'])) { $data['is_schoolmate'] = $all['is_schoolmate']; } -// if (isset($all['is_black'])) { + // if (isset($all['is_black'])) { // $data['is_black'] = $all['is_black']; // } $this->model->whereIn('id', $idsArray)->update($data);