Beispiel #1
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;
 }
Beispiel #2
0
use kartik\widgets\SwitchInput;
use frontend\models\Portones;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\PortonesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Elegir Portón');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="portones-index">

    <div class="jumbotron">
		<h2>
		<?php 
if (\Yii::$app->session->get('porton')) {
    echo 'Activado: ' . \Yii::$app->session->get('porton');
    $cartel = Portones::findOne(\Yii::$app->session->get('porton'))->descripcion;
} else {
    echo 'No ha elegido ningún portón para continuar operando';
    $cartel = '';
}
?>
		</h2>		
		<p class="lead"><?php 
echo $cartel;
?>
</p>		
	</div>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
    <hr/>    
 /**
  * Finds the Portones model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Portones the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Portones::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }