微信标签管理
This commit is contained in:
38
catch/wechat/model/WechatTags.php
Normal file
38
catch/wechat/model/WechatTags.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace catchAdmin\wechat\model;
|
||||
|
||||
use catchAdmin\wechat\model\search\TagSearchTrait;
|
||||
use catcher\base\CatchModel as Model;
|
||||
|
||||
class WechatTags extends Model
|
||||
{
|
||||
use TagSearchTrait;
|
||||
|
||||
protected $name = 'wechat_tags';
|
||||
|
||||
protected $field = [
|
||||
'id', //
|
||||
'tag_id', // 微信 tagId
|
||||
'name', // 标签名称
|
||||
'fans_amount', // 粉丝数量
|
||||
'created_at', // 创建时间
|
||||
'updated_at', // 更新时间
|
||||
'deleted_at', // 软删除
|
||||
];
|
||||
|
||||
|
||||
public function hasManyUsers()
|
||||
{
|
||||
return $this->belongsToMany(WechatUsers::class, 'wechat_user_has_tags', 'user_id', 'tag_id');
|
||||
}
|
||||
}
|
@@ -46,4 +46,9 @@ class WechatUsers extends CatchModel
|
||||
|
||||
const BlOCK = 2; // 拉黑
|
||||
const UNBLOCK = 1; // 取消拉黑
|
||||
|
||||
public function hasManyTags()
|
||||
{
|
||||
return $this->belongsToMany(WechatTags::class, 'wechat_user_has_tags', 'tag_id', 'user_id');
|
||||
}
|
||||
}
|
27
catch/wechat/model/search/TagSearchTrait.php
Normal file
27
catch/wechat/model/search/TagSearchTrait.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CatchAdmin [Just Like ~ ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catchAdmin\wechat\model\search;
|
||||
|
||||
trait TagSearchTrait
|
||||
{
|
||||
/**
|
||||
* 昵称搜索
|
||||
* @time 2020年06月21日
|
||||
* @param $query
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function searchNameAttr($query, $value, $data)
|
||||
{
|
||||
return $query->whereLike('name', $value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user