model->where('openid', $openid)->first(); if (!$thirdlogin && $unionid) { $thirdlogin=$this->model->where('unionid', $unionid)->first(); if ($thirdlogin) { $newThirdlogin=$thirdlogin->toArray(); unset($newThirdlogin['id']); unset($newThirdlogin['created_at']); unset($newThirdlogin['updated_at']); $newThirdlogin['type']=$type; $newThirdlogin['openid']=$openid; $newThirdlogin['unionid']=$unionid; $this->model->create($newThirdlogin); } } if (!$thirdlogin) { return false; } return $this->getUser($thirdlogin); } public function checkQQ($openid) { $thirdlogin=$this->model->where('openid', $openid)->first(); if (!$thirdlogin) { return false; } return $this->getUser($thirdlogin); } /** * @param Thirdlogin $thirdlogin * @return */ protected function getUser($thirdlogin) { if ($thirdlogin->utype == 1) { return $thirdlogin->company()->withTrashed()->first(); } else { return $thirdlogin->member()->withTrashed()->first(); } } public function checkBind($user, $type) { return $this->model->where(['uid'=>$user->id,'utype'=>$user->utype])->whereIn('type', $type)->first(); } public function unBind($type, $user) { return $this->model->where(['uid'=>$user->id,'utype'=>$user->utype])->whereIn('type', $type)->delete(); } }