diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index f7da53f..da39f6e 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -145,7 +145,7 @@ class CustomerController // 执行分页查询 //关联标签tags //关联标签及分组tags.group - $query = Customer::with('tags')->where($where) + $query = Customer::where($where) ->orderBy('id', 'desc'); if (!Util::isEmpty($keyword)) { $query->where(function ($query) use ($keyword) { @@ -219,7 +219,7 @@ class CustomerController return Util::fail([], '记录不存在'); } - $res = Customer::getCustomer($res); + $res = Customer::getCustomer($res,$request); return Util::success($res); } diff --git a/app/model/Customer.php b/app/model/Customer.php index 09a9f0e..54cf548 100644 --- a/app/model/Customer.php +++ b/app/model/Customer.php @@ -59,7 +59,7 @@ class Customer extends Model return $date->format(Carbon::parse($date)->toDateTimeString()); } - public static function getCustomer($customer) + public static function getCustomer($customer,$request = null) { $customer['grade_txt'] = Constants::GRADE[$customer['grade']]; $customer['magnitude_txt'] = Constants::MAGNITUDE[$customer['magnitude']]; @@ -94,6 +94,14 @@ class Customer extends Model $customer['channel_name'] = empty($customer['channel_id'])?'':Channel::where(['id'=>$customer['channel_id']])->value('name'); // $customer['last_follow'] = $last_follow; + if (!empty($request)) { + $language = $request->user['language'] ?: 'en'; + foreach ($customer['tags'] as &$tag) { + $tag['names'] = unserialize($tag['names']); + $tag['name'] = $tag['names'][$language]; + } + } + return $customer; }