Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ParsSettings::find();
     $query->orderBy("id desc");
     $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]);
     $query->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'search', $this->search])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'created', $this->created]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
Archivo: index.php Proyecto: comaw/pars
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <p>
        <a href="<?php 
echo Url::toRoute(['operation/csv', 'pars' => $pars]);
?>
" class="btn btn-warning pull-right"><?php 
echo Yii::t('app', 'Save in CSV');
?>
</a>
        <br>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'pars', 'format' => 'raw', 'value' => function ($data) {
    return isset($data->pars0->search) ? $data->pars0->search : '';
}, 'filter' => ArrayHelper::map(ParsSettings::find()->orderBy("id desc")->all(), 'id', 'search')], 'name', ['attribute' => 'state', 'format' => 'raw', 'value' => function ($data) {
    return ParsSettings::getState($data->state);
}, 'filter' => ParsSettings::listStates()], 'city', ['label' => Yii::t('app', 'Categories'), 'format' => 'raw', 'value' => function ($data) {
    $r = '<ul class="list-unstyled">';
    foreach ($data->categories as $cat) {
        $r .= '<li>' . $cat->name . '</li>';
    }
    $r .= '</ul>';
    return $r;
}, 'filter' => false], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>