/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PlaceDestination::find();
     $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(['id' => $this->id, 'id_direction' => $this->id_direction, 'attribute' => $this->attribute]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Finds the PlaceDestination model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PlaceDestination the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PlaceDestination::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Откуда -> Куда (параметы)';
$this->params['breadcrumbs'][] = ['label' => 'Форма заказа трансфера', 'url' => ['/managecontent/order-form']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="dependency-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Добавить зависимость: "Откуда -> Куда"', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'from' => ['label' => 'Пункт отправления', 'attribute' => 'from', 'content' => function ($model, $key, $index, $column) {
    return PlaceDestination::findOne(['id' => $model->from])->name;
}], 'to' => ['label' => 'Пункт назначения', 'attribute' => 'to', 'content' => function ($model, $key, $index, $column) {
    return PlaceDestination::findOne(['id' => $model->to])->name;
}], 'price', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>