Example #1
0
 /**
  * Finds the Comment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Comment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Comment::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 = Comment::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, 'parent_id' => $this->parent_id, 'material_id' => $this->material_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'public' => $this->public, 'moder' => $this->moder]);
     $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'site', $this->site])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
Example #3
0
use app\components\grid\SetColumn;
use app\components\grid\LinkColumn;
use kartik\date\DatePicker;
use app\modules\admin\modules\comment\models\Comment;
use app\modules\admin\modules\comment\Module;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\admin\modules\comment\models\CommentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('module', 'ADMIN_COMMENTS');
$this->params['breadcrumbs'][] = ['label' => Module::t('module', 'ADMIN'), 'url' => ['/admin/default/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="admin-comment-default-index">
    <?php 
$gridColumn = [['class' => 'yii\\grid\\SerialColumn'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'value' => function ($model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
    return Yii::$app->controller->renderPartial('_expand-row-details', ['model' => $model]);
}, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true], ['attribute' => 'created_at', 'format' => ['date', 'php:d M Y г., H:i:s']], 'author', ['attribute' => 'material_id', 'contentOptions' => [], 'filter' => false, 'content' => function ($data) {
    $materialModel = new $data->namespace();
    return $materialModel->getModelMaterial($data->material_id)->title;
}], ['attribute' => 'type', 'contentOptions' => ['style' => 'width:100px;'], 'headerOptions' => ['style' => 'width:100px;'], 'filter' => true, 'content' => function ($data) {
    return $data->type;
}], ['class' => SetColumn::className(), 'attribute' => 'moder', 'headerOptions' => ['style' => 'width:100px;'], 'filter' => Comment::getModerationsArray(), 'name' => function ($model) {
    return Comment::getModerTitle($model->moder);
}, 'cssCLasses' => [Comment::COMMENT_MODER_ALLOWED => 'success', Comment::COMMENT_MODER_DISALLOWED => 'danger', Comment::COMMENT_MODER_PENDING => 'warning']], ['class' => ActionColumn::className(), 'header' => Module::t('module', 'GRID_ACTIONS'), 'headerOptions' => ['style' => 'width:100px;']]];
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumn, 'responsive' => true, 'hover' => true, 'pjax' => false, 'resizableColumns' => true, 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['class' => 'btn btn-default', 'title' => Yii::t('app', 'Reset Grid')])], '{toggleData}'], 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-comment"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'primary']]);
?>

</div>