/**
  * Finds the Station model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Station the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Station::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Station::find()->where('active!=3');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['IDstation' => $this->IDstation, 'IDcity' => $this->IDcity, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'station', $this->station]);
     return $dataProvider;
 }
Example #3
0
/* @var $form yii\widgets\ActiveForm */
?>

<div class="route-form">

    <?php 
$form = ActiveForm::begin();
?>


    <?php 
echo $model->formRelationalDropDown($form, 'IDstationFrom', Station::find()->where('active!=3')->all(), 'IDstation', 'station');
?>

    <?php 
echo $model->formRelationalDropDown($form, 'IDstationTo', Station::find()->where('active!=3')->all(), 'IDstation', 'station');
?>

    <?php 
echo $model->formActiveDropDown($form);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIDstationTo()
 {
     return $this->hasOne(Station::className(), ['IDstation' => 'IDstationTo']);
 }
Example #5
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use app\modules\admin\models\Station;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\admin\models\RouteSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Routes');
?>
<div class="route-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <p>
        <?php 
echo $searchModel->createButton();
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], $searchModel->gridRelationalColumn('IDstationFrom', Station::find()->all(), 'IDstation', 'station'), $searchModel->gridRelationalColumn('IDstationTo', Station::find()->all(), 'IDstation', 'station'), $searchModel->gridActiveColumn(), $searchModel->actionColumn()]]);
?>

</div>
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStations()
 {
     return $this->hasMany(Station::className(), ['IDcity' => 'IDcity']);
 }