123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class DataGroupUserid extends Model
- {
- protected $schema = [
- 'id' => 'integer',
- 'data_group_id' => 'integer',
- 'uid' => 'integer',
- 'status' => 'integer',
- 'addtime' => 'datetime',
- 'updatetime' => 'datetime',
- 'is_del' => 'integer'
- ];
- protected $createTime = 'addtime';
- protected $updateTime = 'updatetime';
- protected $visible=["id","data_group_id","uid",'status','nickname','mobile',];
- public function userInfo(){
- return $this->belongsTo(\app\user\model\User::class,"uid","account_id")->bind(["nickname","mobile"]);
- }
- public static function GroupIdByUid(int $uid):array{
- return self::where(["uid"=>$uid,"is_del"=>0,"status"=>1])->column("data_group_id");
- }
-
- public static function UidsByGroupId($GroupId):array{
- $list= self::where(['data_group_id'=>$GroupId,'is_del'=>0,'status'=>1])->field('data_group_id,uid')->select();
- $GroupByIds=[];
- if($list->isEmpty()==false){
- foreach ($list as $item){
- $GroupByIds[$item->data_group_id][]=$item->uid;
- }
- }
- return $GroupByIds;
- }
- }
|