示例#1
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     // Create fields for columns
     foreach (Booking::getTableSchema()->columnNames as $column) {
         $field = new TourField();
         $field->tour_id = $this->id;
         $field->name = $column;
         $field->title = "";
         try {
             $field->save(false);
         } catch (Exception $e) {
         }
     }
 }
示例#2
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     // Default name
     if ($this->name == "") {
         $this->name = BookingEx::EXTRA_FIELD_PREFIX . $this->id;
         $this->update();
     }
     $ids = Booking::find()->select(['id'])->where(['tour_id' => $this->tour_id])->column();
     // Insert default values
     foreach ($ids as $booking_id) {
         $fieldValue = new TourFieldValue();
         $fieldValue->booking_id = $booking_id;
         $fieldValue->field_id = $this->id;
         $fieldValue->value = $this->default_value;
         try {
             $fieldValue->insert();
         } catch (Exception $e) {
         }
     }
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     //$query = Booking::find();
     $query = Booking::find()->with("fieldValues");
     // 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, 'tour_id' => $this->tour_id, 'adults' => $this->adults, 'infants' => $this->infants, 'childs' => $this->childs, 'pick_up' => $this->pick_up, 'drop_off' => $this->drop_off, 'time' => $this->time]);
     $query->andFilterWhere(['like', 'address', $this->address]);
     $modeles = $dataProvider->getModels();
     foreach ($modeles as $m) {
         $m->fieldValues;
     }
     return $dataProvider;
 }
示例#4
0
 /**
  * Finds the Booking model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BookingEx the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Booking::findOne($id)) !== null) {
         return new BookingEx($model);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }