diff --git a/app/crm/controller/TagGroupController.php b/app/crm/controller/TagGroupController.php index 7e5dff1..3cf24e1 100644 --- a/app/crm/controller/TagGroupController.php +++ b/app/crm/controller/TagGroupController.php @@ -17,7 +17,7 @@ class TagGroupController extends BaseController { $list = TagGroup::with('tags')->get(); $languageArr = Constants::LANGUAGE; - $language = $request->user['language']; + $language = 'zh_CN'; foreach ($list as &$item) { $item['names'] = unserialize($item['names']); if (in_array($language, $languageArr)) { @@ -52,10 +52,15 @@ class TagGroupController extends BaseController return $this->error( trans('tag_group_id') . trans('not_null')); } - if(empty($tagId)){ - $res = CustomerTag::where(['customer_id' => $customerId, 'group_id' => $groupId])->delete(); - }else{ - $res = CustomerTag::updateOrCreate(['customer_id' => $customerId, 'group_id' => $groupId], ['tag_id' => $tagId]); + + try { + if(empty($tagId)){ + $res = CustomerTag::where(['customer_id' => $customerId, 'group_id' => $groupId])->delete(); + }else{ + $res = CustomerTag::updateOrCreate(['customer_id' => $customerId, 'group_id' => $groupId], ['tag_id' => $tagId]); + } + } catch (\Throwable $e) { + return $this->error($e->getMessage()); } if($res){ diff --git a/config/route.php b/config/route.php index 4fd7025..b694023 100644 --- a/config/route.php +++ b/config/route.php @@ -104,5 +104,8 @@ Route::group('/crm', function () { Route::any('/customer/statistics', [app\crm\controller\CustomerController::class, 'statistics']); Route::any('/customer/getChannel', [app\crm\controller\CustomerController::class, 'getChannel']); Route::any('/customer/getCountry', [app\crm\controller\CustomerController::class, 'getCountry']); + + Route::any('/tagGroup/list', [app\crm\controller\TagGroupController::class, 'list']); + Route::any('/tagGroup/updatePivot', [app\crm\controller\TagGroupController::class, 'updatePivot']); });