/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SocialServiceManager::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'faculty_id' => $this->faculty_id]); return $dataProvider; }
/** * 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.'); } }
/** * @return string */ public function actionListSocialServiceManagers() { $dataProvider = new ActiveDataProvider(['query' => SocialServiceManager::find()]); return $this->render('SocialServiceManager/index', ['dataProvider' => $dataProvider]); }
/** * 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; }
/** * @return \yii\db\ActiveQuery */ public function getSocialServiceManagers() { return $this->hasMany(SocialServiceManager::className(), ['faculty_id' => 'id']); }
public function testValidateReturnsTrueIfParametersAreSet() { $configurationParams = ['username' => 'miles', 'email' => '*****@*****.**', 'password_hash' => \Yii::$app->getSecurity()->generatePasswordHash('admin')]; $user = new SocialServiceManager($configurationParams); $this->assertTrue($user->validate(), "User with set parameters should validate"); }