Пример #1
0
 /**
  * Update creator when update user name
  * @see \yii\db\BaseActiveRecord::afterSave($insert, $changedAttributes)
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (!$insert && array_key_exists('name', $changedAttributes)) {
         $this->attachBehavior('UserBehavior', new UserBehavior());
         $this->updateCreator($this->_id, $this->name);
     }
 }