本文整理汇总了PHP中app\models\Users::roles方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::roles方法的具体用法?PHP Users::roles怎么用?PHP Users::roles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::roles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_encode
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel app\models\UsersSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Users');
?>
<div class="user-index">
<br>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'email', 'format' => 'raw', 'value' => function ($data) {
return Html::a($data->email, Url::to(['update', 'id' => $data->id]));
}], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => Users::$statuses, 'format' => 'raw', 'attribute' => 'status', 'url' => ['ajax-update'], 'type' => 'select', 'display' => 'colors', 'value' => function ($data) {
return Users::getStatus($data->status);
}, 'editableOptions' => function ($model) {
return ['source' => Users::$statuses, 'value' => $model->status];
}], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => Users::roles(), 'format' => 'raw', 'attribute' => 'role', 'url' => ['ajax-update'], 'value' => function ($data) {
return Users::getRole($data->role);
}, 'type' => 'select', 'editableOptions' => function ($model) {
return ['source' => Yii::$app->user->identity->getEditableRoles($model->id), 'sourceCache' => false];
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
<script>
function colors(value, sourceData) {
var selected = $.grep(sourceData, function (o) {
return value == o.value;
}),
colors = <?php
echo json_encode(Users::$status_colors);
?>