public function beforeSave($insert) { if (parent::beforeSave($insert)) { $model = new AssignRole(); if ($this->parent_id == NULL) { $this->parents = $this->id . '-'; $model->save(); } else { $pparents = $model->findOne($this->parent_id)->parents; $this->parents = $pparents . $this->id . '-'; $model->save(); } return true; } return false; }
/** * Finds the AssignRole model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AssignRole the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AssignRole::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }