如何在Yii框架中编辑自动生成的模型?

protected function beforeSave()
{
  if(parent::beforeSave())
  {
     if($this->isNewRecord)
     {
        $this->create_time = $this->update_time=time();
        $this->author_id = Yii::app()->user->id;
     }
     else
        $this->update_time = time();
     return true;
 }
 else
    return false;

}

Above is a sample code of model. Can anybody tell me how to edit such automatic generated code in Yii?

       $this->author_id = Yii::app()->user->id;

It's bad practice. Because you model depend from your environment. in consequence of dependecy you cant use Unit-test and console command for creating models.