public function afterSave() { if ($this->picture instanceof CUploadedFile && $this->picture->error == UPLOAD_ERR_OK) { $name = "picture{$this->id}.{$this->picture->extensionName}"; $this->picture->saveAs($this->getPicturePath($name)); $this->updateByPk($this->id, array('picture' => $name)); } parent::afterSave(); }