コード例 #1
0
ファイル: LkController.php プロジェクト: sergey-exu/kio
 public function actionData()
 {
     if (($model = Students::find()->where(['user_id' => Yii::$app->user->identity->id])->one()) == null) {
         $model = new Students();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['data']);
     } else {
         return $this->render('data', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: StudentsSearch.php プロジェクト: sergey-exu/kio
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Students::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'middleName', $this->middleName])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'education', $this->education])->andFilterWhere(['like', 'specialty_one', $this->specialty_one])->andFilterWhere(['like', 'specialty_one_docs', $this->specialty_one_docs])->andFilterWhere(['like', 'specialty_two', $this->specialty_two])->andFilterWhere(['like', 'specialty_two_docs', $this->specialty_two_docs])->andFilterWhere(['like', 'specialty_three', $this->specialty_three])->andFilterWhere(['like', 'specialty_three_docs', $this->specialty_three_docs]);
     return $dataProvider;
 }