/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserStudent::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->joinWith('userStudent'); $query->andFilterWhere(['usr_is_teacher' => $this->usr_is_teacher, 'usr_is_admin' => $this->usr_is_admin, 'usr_is_su' => $this->usr_is_su, 'usr_active' => $this->usr_active]); $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'usr_id', $this->usr_id])->andFilterWhere(['like', 'usr_name', $this->usr_name])->andFilterWhere(['like', 'usr_pass', $this->usr_pass])->andFilterWhere(['like', 'usr_email', $this->usr_email])->andFilterWhere(['like', 'student.st_fname', $this->usr_type_id]); return $dataProvider; }
/** * Finds the UserStudent model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return UserStudent the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserStudent::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }