标签统计客户
This commit is contained in:
@@ -3,8 +3,10 @@
|
|||||||
namespace app\crm\controller;
|
namespace app\crm\controller;
|
||||||
|
|
||||||
use app\crm\controller\BaseController;
|
use app\crm\controller\BaseController;
|
||||||
|
use app\crm\model\Customer;
|
||||||
use app\crm\model\CustomerTag;
|
use app\crm\model\CustomerTag;
|
||||||
use app\crm\model\TagGroup;
|
use app\crm\model\TagGroup;
|
||||||
|
use app\crm\model\Tag;
|
||||||
use app\crm\utils\Util;
|
use app\crm\utils\Util;
|
||||||
use config\constants\Constants;
|
use config\constants\Constants;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
@@ -15,6 +17,8 @@ class TagGroupController extends BaseController
|
|||||||
// 列表
|
// 列表
|
||||||
public function list(Request $request)
|
public function list(Request $request)
|
||||||
{
|
{
|
||||||
|
$uid = $request->user->uid;
|
||||||
|
$scene = $request->input("scene");
|
||||||
$list = TagGroup::with('tags')->get();
|
$list = TagGroup::with('tags')->get();
|
||||||
$languageArr = Constants::LANGUAGE;
|
$languageArr = Constants::LANGUAGE;
|
||||||
$language = 'zh_CN';
|
$language = 'zh_CN';
|
||||||
@@ -28,6 +32,10 @@ class TagGroupController extends BaseController
|
|||||||
if (in_array($language, $languageArr)) {
|
if (in_array($language, $languageArr)) {
|
||||||
$tag['name'] = $tag['names'][$language];
|
$tag['name'] = $tag['names'][$language];
|
||||||
}
|
}
|
||||||
|
if($scene == 'customers'){
|
||||||
|
// 统计每个标签关联的客户数量,增加user_id条件
|
||||||
|
$tag['count'] = $tag->customers()->where('user_id', $uid)->count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user