creocoder\taggable\TaggableQueryBehavior::anyTagValues PHP Method

anyTagValues() public method

Gets entities by any tags.
public anyTagValues ( string | string[] $values, string | null $attribute = null ) : ActiveQuery
$values string | string[]
$attribute string | null
return yii\db\ActiveQuery the owner
    public function anyTagValues($values, $attribute = null)
    {
        $model = new $this->owner->modelClass();
        $tagClass = $model->getRelation($model->tagRelation)->modelClass;
        $this->owner->innerJoinWith($model->tagRelation, false)->andWhere([$tagClass::tableName() . '.' . ($attribute ?: $model->tagValueAttribute) => $model->filterTagValues($values)])->addGroupBy(array_map(function ($pk) use($model) {
            return $model->tableName() . '.' . $pk;
        }, $model->primaryKey()));
        return $this->owner;
    }