From f248e9b16341b6d44dd59bd9e7fe366a1879ca82 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Tue, 20 Jan 2026 19:04:35 +0800 Subject: [PATCH] update --- app/Http/Controllers/Admin/OtherController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index 907b990..25fb460 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -174,21 +174,21 @@ class OtherController extends CommonController ]; } - // 全国数据 + // 全国数据(与 study 的 address 口径一致:company_address 或 company_city 的 like 匹配,含「市」的取前部如 上海市→上海 以同时匹配 上海/上海市) $countryArea = Company::approvedStudents()->groupBy('company_city')->whereNotNull('company_city')->get(['company_city']); $country = []; foreach ($countryArea as $item) { - $total = User::whereHas('company', function ($query) use ($item) { - $query->where('company_city', $item->company_city); + $term = preg_replace('/市$/', '', $item->company_city) ?: $item->company_city; + $total = User::whereHas('company', function ($query) use ($term) { + $query->where('company_address', 'like', '%' . $term . '%') + ->orWhere('company_city', 'like', '%' . $term . '%'); })->where('is_schoolmate', 1)->count(); if (empty($total)) { continue; } $country[] = [ 'area' => $item->company_city, - 'total' => User::whereHas('company', function ($query) use ($item) { - $query->where('company_city', $item->company_city); - })->where('is_schoolmate', 1)->count() + 'total' => $total, ]; }