Exemple #1
0
 public function beforeValidate()
 {
     if (!$this->userValidate) {
         return parent::beforeValidate();
     }
     if (parent::beforeValidate()) {
         if ($this->hasAttribute('sort_num')) {
             if ($this->sort_num === null || $this->sort_num === '') {
                 $this->sort_num = Constants::getSortNum();
             }
         }
         if ($this->hasAttribute('created_at')) {
             if (empty($this->created_at)) {
                 $this->created_at = time();
             }
         }
         if ($this->hasAttribute('updated_at')) {
             $this->updated_at = time();
         }
         if ($this->hasAttribute('created_by')) {
             if (empty($this->created_by)) {
                 $this->created_by = LuLu::getIdentity()->username;
             }
         }
         if ($this->hasAttribute('updated_by')) {
             if (empty($this->updated_by)) {
                 $this->updated_by = LuLu::getIdentity()->username;
             }
         }
         return true;
     }
     return false;
 }
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if ($this->hasAttribute('sort_num')) {
             if ($this->sort_num === null || $this->sort_num === '') {
                 $this->sort_num = Constants::getSortNum();
             }
         }
         if ($this->hasAttribute('created_at')) {
             if ($this->created_at == null || $this->created_at == '') {
                 $this->created_at = time();
             }
         }
         if ($this->hasAttribute('updated_at')) {
             $this->updated_at = time();
         }
         return true;
     }
     return false;
 }