Gets entities by any languages.
@param string|string[] $values
@param string|null $attribute
@return \yii\db\ActiveQuery the owner
329475
public function anyLanguageValues($values, $attribute = null)
    {
        /** @var \yii\db\ActiveRecord $model */
        $model = new $this->owner->modelClass();
        $languageClass = $model->getRelation($model->languageRelation)->modelClass;

        $this->owner
            ->innerJoinWith($model->languageRelation, false)
            ->andWhere([$languageClass::tableName() . '.' . ($attribute ?: $model->languageValueAttribute) => $model->filterLanguageValues($values)])
            ->addGroupBy(array_map(function ($pk) use ($model) {
                return $model->tableName() . '.' . $pk;
            }, $model->primaryKey()));

        return $this->owner;
    }
615814
private function getAttributeValues($attribute, $attributeValues)
    {
        $values = [];
        foreach ($attributeValues as $attributeValue) {
            if ($attribute['id'] == $attributeValue['attributeId']) {
                $values[] = $attributeValue;
            }
        }

        return $values;
    }
202766
public function values(array $values) : QueryBuilder
    {
        $args    = func_get_args();
        $columns = [];
        $_values = [];

        foreach($values as $key => $value) {
            preg_match("/\(JSON\)\s*([\w]+)/i", $key, $jsonTag);

            if(
                is_array($value) ||
                is_object($value)
            ) {
                if(isset($jsonTag[0])) {
                    $key       = preg_replace('/\(JSON\)\s*([\w]+)/i', '$1', $key);
                    $_values[] = $this->getQuoted(json_encode($value));
                } else {
                    $_values[] = $this->getQuoted(serialize($value));
                }
            } else if(is_bool($value)) {
                $_values[] = ($value ? 1 : 0);
            } else if(is_null($value)) {
                $_values[] = "NULL";
            } else {
                $_values[] = $this->getQuoted($value);
            }

            $columns[] = "`". $this->sanitize($key) ."`";
        }

        $this->_query[] = "(". implode(", ", $columns) .")";
        $this->_query[] = "VALUES";
        $this->_query[] = "(". implode(", ", $_values) .")";

        return $this;
    }
49871
protected function getValuesByAttribute(AttributeInterface $attribute)
    {
        if (null === $this->valuesByAttributes) {
            $this->valuesByAttributes = [];
        }

        if (!array_key_exists($attribute->getCode(), $this->valuesByAttributes)) {
            $this->valuesByAttributes[$attribute->getCode()] = [];
            foreach ($this->values as $value) {
                if ($value->getAttributeCode() === $attribute->getCode()) {
                    $this->addValueByAttribute($value);
                }
            }
        }

        return $this->valuesByAttributes[$attribute->getCode()];
    }
687738
public function findManyBy($attribute, array $values = [], $columns = [])
    {
        $query = $this->select($columns);

        foreach ($values as $value) {
            $query->orWhere([$attribute => $value]);
        }

        return $query->get();
    }
470241
public function findAllBy($attribute, $value, $columns = ['*'])
    {
        return $this->model->where($attribute, '=', $value)->get($columns);
    }
758186
public function relatedByCategoryValues($values, $attribute = null)
    {
        return $this->anyCategoryValues($values, $attribute)->addOrderBy(new Expression('COUNT(*) DESC'));
    }
183794
public static function allAttributesFrom(string $attribute) {
		$modules = self::all();
		$result = [];
		foreach ($modules as $module) {
			if ($module->$attribute) {
				$attr = $module->$attribute;
				
				if (is_array($attr)) {
					foreach ($attr as $item) {
						$result[] = $item;
					}
				}
				else {
					$result[] = $attr;
				}
			}
		}
		
		return empty($result) ? null : $result;
	}
1299162
public function allCategoryValues($values, $attribute = null)
    {
        $model = new $this->owner->modelClass();

        return $this->anyCategoryValues($values, $attribute)->andHaving(new Expression('COUNT(*) = ' . count($model->filterCategoryValues($values))));
    }
1163461
public function attr($attribute, $value = null)
    {
        if (is_array($attribute)) return $this->attributes($attribute);
        if ($value) return $this->attributes(array($attribute => $value));
    }
57589
private function loadTranslation($language) {
        $translation = null;
        /** @var \yii\db\ActiveQuery $relation */
        $relation = $this->owner->getRelation($this->relation);
        /** @var ActiveRecord $class */
        $class = $relation->modelClass;
        $language = strtolower($language);
        if ($this->owner->getPrimarykey()) {
            $translation = $class::findOne(
                            [$this->languageField => $language, key($relation->link) => $this->owner->getPrimarykey()]
            );
        }
        if ($translation === null) {
            $translation = new $class;
            $translation->{key($relation->link)} = $this->owner->getPrimaryKey();
            $translation->{$this->languageField} = $language;
        }
        return $translation;
    }
632569
public function getAttributeValues()
    {
        return (new CmsAttributeValueQuery)
            ->join('cms_attribute')->on('cms_attribute_id')
            ->join('cms_attribute_value_relation')->on('id', 'cms_attribute_value_id')
            ->join('cms_attribute_type', 'cms_attribute')->on('cms_attribute_type_id')
            ->where('object', 'cms_attribute_value_relation')->equals($this->_object)
            ->where('objectId', 'cms_attribute_value_relation')->equals($this->_objectId)
            ->find();
    }
1248347
public function findWhereIn($attribute, $values, $columns = ['*'], $with = [])
    {
        $values   = $this->castRequest($values);
        $cacheKey = $this->generateKey([$attribute, $values, $columns, $with]);

        return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $values, $columns, $with) {
            return $this->model->with($with)
                ->whereIn($attribute, $values)
                ->get($columns);
        });
    }
1216182
public function get($attribute, $default = null)
    {
        list($relationArray, $column, $jsonArray) = FieldNameSlicer::split($attribute);
        $key = join('.', array_merge($relationArray, [$column]));
        $value = data_get($this->data, $key);

        if ($jsonArray) {
            $value = is_string($value) ? json_decode($value) : $value;

            return data_get($value, join('.', $jsonArray), $default);
        }

        return is_null($value) ? $default : $value;
    }
1233150
public function firstOrNew(array $attributes, array $values = [])
    {
        if (is_null($instance = $this->where($attributes)->first())) {
            $instance = $this->related->newInstance($attributes + $values);

            $this->setForeignAttributesForCreate($instance);
        }

        return $instance;
    }
1071697
public function fetchValues($tag, $attribute)
    {
        $values = array();

        // loop through each tag in the dom and add it to the array
        foreach ($this->getElementsByTagName($tag) as $element) {
            /* @var $element \DOMElement */
            $values[] = $element->getAttribute($attribute);
        }

        return $values;
    }
1062267
public function virtuals($attribute = null)
    {
        $fields = [];
        foreach ($this->_columns as $name => $field) {
            if (empty($field['virtual'])) {
                continue;
            }
            $fields[] = $name;
        }
        return $fields;
    }