/** * Finds the SocialServiceManager model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SocialServiceManager the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SocialServiceManager::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Figure it out the person role and returns an * object of that type. */ public function getUserRole() { $rol = null; if (Yii::$app->user->can('projectManager')) { return $rol = ProjectManager::findOne(['user_id' => $this->id]); } if (Yii::$app->user->can('socialServiceManager')) { return $rol = SocialServiceManager::findOne(['user_id' => $this->id]); } if (Yii::$app->user->can('student')) { return $rol = Student::findOne(['user_id' => $this->id]); } return $rol; }