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