/** * Get all members. * @return BaseUserQuery */ public function getMembers($type = 'all') { $model = User::buildNoInitModel(); $query = $this->hasMany(User::className(), [$model->guidAttribute => 'member_guid'])->via('memberItems'); $type = (array) $type; foreach ($type as $key => $t) { if (array_key_exists($t, static::$types)) { unset($type[$key]); } $query = $query->andWhere(['type' => $type]); } return $query; /* SELECT * FROM `rho_user` WHERE <Organization::$member_guid> IN (...) */ }
/** * * @param User $following * @return BaseUserQuery */ public function isFollowing($following) { $model = User::buildNoInitModel(); return $this->getFollowings()->andWhere([$model->guidAttribute => $following->guid])->exists(); }