public function uniqueForEntity($attribute, $params)
    {
        $translationsIds = ProductTranslation::find()
            ->asArray()->where(['product_id' => $this->product_id])->select('id')->all();

        $seoUrl = SeoData::find()
            ->where(['entity_name' => ProductTranslation::className(), 'seo_url' => $this->seoUrl])
            ->andWhere(['not in', 'entity_id', ArrayHelper::getColumn($translationsIds, 'id')])
            ->one();

        if (!empty($seoUrl)) {
            $this->addError($attribute, \Yii::t('shop', 'Such url already exists'));
        }
    }
public function uniqueForEntity($attribute, $params)
    {
        $translationsIds = ProductTranslation::find()
            ->asArray()->where(['product_id' => $this->product_id])->select('id')->all();

        $seoUrl = SeoData::find()
            ->where(['entity_name' => ProductTranslation::className(), 'seo_url' => $this->seoUrl])
            ->andWhere(['not in', 'entity_id', ArrayHelper::getColumn($translationsIds, 'id')])
            ->one();

        if (!empty($seoUrl)) {
            $this->addError($attribute, \Yii::t('shop', 'Such url already exists'));
        }
    }
public function uniqueForEntity ( $ attribute , $ params ) { $ translationsIds = ProductTranslation :: find ( ) -> asArray ( ) -> where ( [ 'product_id' => $ this -> product_id ] ) -> select ( 'id' ) -> all ( ) ; $ seoUrl = SeoData :: find ( ) -> where ( [ 'entity_name' => ProductTranslation :: className ( ) , 'seo_url' => $ this -> seoUrl ] ) -> andWhere ( [ 'not in' , 'entity_id' , ArrayHelper :: getColumn ( $ translationsIds , 'id' ) ] ) -> one ( ) ; if ( ! empty ( $ seoUrl ) ) { $ this -> addError ( $ attribute , \ Yii :: t ( 'shop' , 'Such url already exists' ) ) ; } }
Validation rule which checks if such seo url is already exist in current entity
@param $attribute
@param $params
Validation rule which checks if such seo url is already exist in current entity