Exemple #1
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use app\modules\admin\components\grid\SetColumn;
use app\modules\admin\components\grid\LinkColumn;
use app\modules\admin\Module;
use app\modules\user\models\User;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('app', 'ADMIN_USER');
$this->params['breadcrumbs'][] = ['label' => Module::t('app', 'ADMIN'), 'url' => ['default/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', ['class' => LinkColumn::className(), 'attribute' => 'username'], 'email:email', ['attribute' => 'status', 'class' => SetColumn::className(), 'name' => 'UserStatusName', 'cssCLasses' => [User::STATUS_ACTIVE => 'success', User::STATUS_BLOCKED => 'danger', User::STATUS_WAIT => 'warning']], 'created_at:datetime']]);
?>

</div>
Exemple #2
0
use app\modules\admin\components\grid\LinkColumn;
use app\modules\admin\components\grid\SetColumn;
use app\modules\main\models\Article;
use app\modules\admin\components\widgets\AdminBoxWidget;
use yii\grid\SerialColumn;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('app', 'ADMIN_ARTICLE');
$this->params['breadcrumbs'][] = ['label' => Module::t('app', 'ADMIN'), 'url' => ['default/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="admin-article-index">

    <?php 
AdminBoxWidget::begin(['type' => AdminBoxWidget::TYPE_INFO, 'title' => Html::a('<i class="fa fa-plus-circle"></i>' . ' ' . Module::t('app', 'ADMIN_ARTICLE_ADD'), ['create'], ['class' => 'btn btn-success btn-xs'])]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'summary' => false, 'columns' => [['class' => SerialColumn::className()], ['class' => LinkColumn::className(), 'attribute' => 'title'], ['attribute' => 'category_id', 'value' => function ($data) {
    return $data->category->title;
}], ['attribute' => 'author_id', 'value' => function ($data) {
    return $data->author->username;
}], ['class' => SetColumn::className(), 'attribute' => 'status', 'name' => 'ArticleStatusName', 'cssCLasses' => [Article::ARTICLE_ACTIVE => 'success', Article::ARTICLE_INACTIVE => 'warning']], ['attribute' => 'created_at', 'format' => 'datetime']]]);
?>

    <?php 
AdminBoxWidget::end();
?>

</div>