public function beforeSave() { if ($this->isNewRecord) { $this->created_at = time(); } return parent::beforeSave(); }
public function beforeSave() { if (!is_numeric($this->end_at)) { $this->end_at = strtotime($this->end_at); } if (!is_numeric($this->start_at)) { $this->start_at = strtotime($this->start_at); } if ($this->getIsNewRecord()) { $this->_createNew(); } else { $this->_updateExisting(); } return parent::beforeSave(); }
/** * @return bool|void */ public function beforeSave() { if ($this->isNewRecord) { if (empty($this->created_at)) { $this->created_at = time(); if (!Yii::app()->user->isGuest) { $this->author_id = Yii::app()->user->id; } } } else { $this->edited_at = time(); if (!Yii::app()->user->isGuest) { $this->editor_id = Yii::app()->user->id; } } return parent::beforeSave(); }