framework/validators/UniqueValidator.php
private function prepareConditions($targetAttribute, $model, $attribute)
    {
        if (is_array($targetAttribute)) {
            $conditions = [];
            foreach ($targetAttribute as $k => $v) {
                $conditions[$v] = is_int($k) ? $model->$v : $model->$k;
            }
        } else {
            $conditions = [$targetAttribute => $model->$attribute];
        }

        $targetModelClass = $this->getTargetClass($model);
        if (!is_subclass_of($targetModelClass, 'yii\db\ActiveRecord')) {
            return $conditions;
        }

        /** @var ActiveRecord $targetModelClass */
        return $this->applyTableAlias($targetModelClass::find(), $conditions);
    }
private function prepareConditions($targetAttribute, $model, $attribute)
    {
        if (is_array($targetAttribute)) {
            $conditions = [];
            foreach ($targetAttribute as $k => $v) {
                $conditions[$v] = is_int($k) ? $model->$v : $model->$k;
            }
        } else {
            $conditions = [$targetAttribute => $model->$attribute];
        }

        $targetModelClass = $this->getTargetClass($model);
        if (!is_subclass_of($targetModelClass, 'yii\db\ActiveRecord')) {
            return $conditions;
        }

        /** @var ActiveRecord $targetModelClass */
        return $this->applyTableAlias($targetModelClass::find(), $conditions);
    }
Processes attributes' relations described in $targetAttribute parameter into conditions, compatible with
[[\yii\db\Query::where()|Query::where()]] key-value format.

@param string|array $targetAttribute the name of the [[\yii\db\ActiveRecord|ActiveRecord]] attribute that
should be used to validate the uniqueness of the current attribute value. You may use an array to validate
the uniqueness of multiple columns at the same time. The array values are the attributes that will be
used to validate the uniqueness, while the array keys are the attributes whose values are to be validated.
If the key and the value are the same, you can just specify the value.
@param Model $model the data model to be validated
@param string $attribute the name of the attribute to be validated in the $model

@return array conditions, compatible with [[\yii\db\Query::where()|Query::where()]] key-value format.