예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comments::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => '']]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'username' => $this->username, 'module' => $this->module, 'FROM_UNIXTIME(created_at, "%d.%m.%Y")' => $this->created_at]);
     $query->andFilterWhere(['like', 'post', $this->post])->andFilterWhere(['like', 'post', $this->post])->andFilterWhere(['like', 'username', $this->username]);
     return $dataProvider;
 }
예제 #2
0
파일: index.php 프로젝트: psych88/fifa
<div class="header">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
</div>

<div class="comments-index">

    <div class="well">

        <?php 
Pjax::begin();
?>
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'comments_tbl', 'columns' => [['class' => CheckboxColumn::classname()], 'id', 'post:ntext', ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.yyyy'], 'options' => array('width' => '225px'), 'filter' => \yii\jui\DatePicker::widget(['dateFormat' => 'dd.MM.yyyy', 'model' => $searchModel, 'attribute' => 'created_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])], ['attribute' => 'post_id', 'options' => array('width' => '80')], ['attribute' => 'module', 'options' => array('width' => '80'), 'filter' => Html::activeDropDownList($searchModel, 'module', \yii\helpers\Arrayhelper::map(Comments::find()->groupBy('module')->all(), 'module', 'module'), ['class' => 'form-control', 'prompt' => 'Все'])], ['attribute' => 'username', 'format' => 'raw', 'value' => function ($model) {
    return Html::a($model['username'], ['/user/' . $model['username']], ['target' => '_blank']);
}], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Действия', 'headerOptions' => ['width' => '80']]]]);
?>
 



<p> 
  <?php 
echo Html::a('Удалить выбранные', ['massdelete'], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Вы уверены?', 'data-method' => 'post']]);
?>
  
</p>

<?php