public function getCategory() { if (!is_null($this->id)) { return Category::model()->findByPk($this->id); } return new Category(); }