Exemple #1
0
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         TourFields::deleteAll(['tour_id' => $this->id]);
         return true;
     } else {
         return false;
     }
 }
Exemple #2
0
 public function actionUpdate($id)
 {
     $model = TourFields::findOne($id);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save();
         if ($model->tour_id > 0) {
             return $this->redirect("/tour/{$model->tour_id}");
         } else {
             return $this->redirect("/tour");
         }
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TourFields::find();
     $query->joinWith('tour');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     // add conditions that should always apply here
     $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, 'sort' => $this->sort]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'tour.name', $this->tour_id]);
     return $dataProvider;
 }
Exemple #4
0
 protected function findFieldModel($id)
 {
     if (($model = TourFields::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTourFields()
 {
     return $this->hasMany(TourFields::className(), ['tour_id' => 'id'])->orderBy(['sort' => SORT_ASC]);
 }