Exemplo n.º 1
0
 public function actionElegir($backUrl = null)
 {
     $model = Portones::find()->where(['habilitado' => true])->all();
     if (empty($model)) {
         return $this->render('deshabilitado');
     }
     if (isset(Yii::$app->request->post()['eligeporton'])) {
         \Yii::$app->session->set('porton', Yii::$app->request->post()['eligeporton']);
         if ($backUrl) {
             return $this->redirect([$backUrl]);
         }
     }
     return $this->render('elegir', ['model' => $model]);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Portones::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, 'habilitado' => $this->habilitado]);
     $query->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }