/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TourField::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, 'tour_id' => $this->tour_id, 'position' => $this->position]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTourFields()
 {
     return $this->hasMany(TourField::className(), ['tour_id' => 'id']);
 }
 /**
  * Finds the TourField model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TourField the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TourField::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTourField()
 {
     return $this->hasOne(TourField::className(), ['id' => 'tour_field_id']);
 }
 protected function getReservationFieldsProvider($id)
 {
     $book = \app\models\Book::findOne($id);
     $tourFields = \app\models\TourField::find()->where(['tour_id' => $book->tour_id])->orderBy('position')->all();
     $bookValues = \app\models\BookValue::find()->where(['book_id' => $book->id])->indexBy('tour_field_id')->all();
     //print '<pre>'; print_r($tourFields); die();
     foreach ($tourFields as $field) {
         $data[] = ['name' => $field->name, 'value' => array_key_exists($field->id, $bookValues) ? $bookValues[$field->id]->value : ''];
     }
     //print '<pre>'; print_r($data); die();
     $provider = new \yii\data\ArrayDataProvider(['allModels' => $data]);
     return $provider;
 }