public function checkUniqueness($attribute, $params)
{
$data = self::find()->where(['alive'=>1, 'name'=>$this->login])->all();
if(!empty($data)) {
$this->addError($attribute, Yii::t('app', 'This login is occupied'));
}
}
['login', 'checkUniqueness', 'on' => self::SCENARIO_INSERT],
$collision = self::find()->where(['and', ['alive' => 1], ['name' => $this->login], ['!=', 'id', $this->id]])->count();
if ($collision > 0) {
...
}
public function checkUniqueness($attribute, $params)
{
$data = self::find()->where([ 'name'=>$this->login])->one();
if(!is_null($data)){
$this->addError($attribute, Yii::t('app', 'This login is occupied'));
}
}