Exemplo n.º 1
0
 public function beforeSave($insert)
 {
     if (empty($this->author)) {
         $this->author = \Yii::$app->user->identity->username;
     }
     if ($this->isNewRecord) {
         $this->creator = \Yii::$app->user->id;
     }
     if ($this->isAttributeChanged('published')) {
         if ($this->published == 1 && empty($this->publishDate)) {
             $this->publishDate = time();
         } else {
             $this->unpublishDate = time();
         }
     }
     $this->updated = time();
     $this->updateIndexes();
     return parent::beforeSave($insert);
     // TODO: Change the autogenerated stub
 }