本文整理汇总了PHP中app\models\Users::getRole方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::getRole方法的具体用法?PHP Users::getRole怎么用?PHP Users::getRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::getRole方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all Record models.
* @return mixed
*/
public function actionIndex()
{
$teClass = new teClass();
$admin = new Users();
$searchModel = new RecordSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$id = $searchModel->searchID();
// var_dump($id);
// die;
$academy = $searchModel->searchacademy();
$te_id = $searchModel->searchte_id();
$array = $admin->getRole($te_id);
//根据不同角色返回不同的查看权限
$classArray = $teClass->getRoleClass($id, $te_id, $academy);
$major = $teClass->getClass($id, $te_id, $academy);
// var_dump($major);die;
return $this->render('index', ['te_id' => $te_id, 'array' => $array, 'academy' => $academy, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'classArray' => $classArray, 'major' => $major]);
}
示例2: json_encode
/* @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);
?>
;