public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if (!$insert && $this->defaulted) { Yii::$app->db->createCommand()->update(self::tableName(), ['defaulted' => Constant::BOOLEAN_FALSE], '[[group_name]] = :groupName AND [[id]] <> :id', [':groupName' => $this->group_name, ':id' => $this->id])->execute(); } }