public function beforeSave()
 {
     if ($this->parent != '' and $this->parent != 0) {
         $parent = $this->model()->resetScope()->findByPk((int) $this->parent);
         if ($this->slug == '') {
             $this->slug = $parent->slug . '-' . $this->name;
         } else {
             if ($this->isNewRecord) {
                 $this->slug = $parent->slug . '-' . $this->slug;
             } else {
                 $model = $this->model()->resetScope()->findByPk((int) $this->term_id);
                 if ($model->slug != $this->slug) {
                     $this->slug = $parent->slug . '-' . $this->slug;
                 }
             }
         }
     } else {
         if ($this->slug == '') {
             $this->slug = $this->name;
         }
     }
     $this->images = str_replace(Helper::rootImg('content'), '', $this->images);
     $this->taxonomy = $this->_taxonomy;
     $this->name = Ucfirst($this->name);
     return parent::beforeSave();
 }
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return Term the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }