belongsTo(User::class); } public function community() { return $this->belongsTo(Community::class); } public function profile() { return $this->belongsTo(UserProfile::class, 'user_id'); } public function updateCommunityNick($tid, $owner, $accid, $nick) { try { $im_service = new IMService(env('IM_APP_KEY'), env("IM_APP_SECRET")); $result = $im_service->updateGroupNick($tid,$owner,$accid,$nick); if ($result['code'] != 200) {//失败 throw new \Exception("网易修改群昵称失败", 1); } return true; } catch (\Exception $e) { $this->getError($e); return false; } } public function leaveCommunity($tid, $accid) { try { $im_service = new IMService(env('IM_APP_KEY'), env("IM_APP_SECRET")); $result = $im_service->leaveGroup($tid,$accid); if ($result['code'] != 200) {//失败 throw new \Exception("退出网易群失败", 1); } return true; } catch (\Exception $e) { $this->getError($e); return false; } } }