where('is_del',0); } public function getDepartNameAttr($v,$row){ $item = new AccountItem(); $depart=$item->where(['account_id'=>$row['id']])->with(['depart'])->findOrEmpty(); return $depart->isEmpty()?'':$depart->depart_name; } public function getCompanyRelatonAttr($v,$row){ $item = new AccountCompany(); $company=$item->where(['account_id'=>$row['id'],'is_del' => 0])->column("companyCode,companyCode companyNo,companyName,companyName company_name,company_type,is_main,status"); return $company; } public function UserInfo(){ return $this->belongsTo(User::class,'id','account_id')->bind(["nickname","openId"]); } public function AccountItem(){ return $this->belongsTo(AccountItem::class,'id','account_id')->bind(["itemid"]); } public function getIsWxAttr($v,$row){ return $row['openId']==''?0:1; } public function setIsWxAttr($v,$data){ if($v==0){ $this->UserInfo()->where('account_id',$data['id'])->update(['openId'=>'']); } } }