当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getRole方法代码示例

本文整理汇总了PHP中common\models\User::getRole方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getRole方法的具体用法?PHP User::getRole怎么用?PHP User::getRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\User的用法示例。


在下文中一共展示了User::getRole方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Logs in a user using the provided username and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     /** @var User $user */
     $user = $this->getUser();
     if ($this->validate() && isset(User::getRole($user->id)['admin'])) {
         return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         return false;
     }
 }
开发者ID:viktornord,项目名称:gh-php-blog,代码行数:15,代码来源:LoginForm.php

示例2: function

use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Users';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'username', 'avatar', ['attribute' => 'role', 'value' => function ($model) {
    return User::getRole($model->role)['name'];
}], 'created_at:datetime', 'updated_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
开发者ID:grutabow,项目名称:getyii,代码行数:30,代码来源:index.php

示例3: json_encode

use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel common\models\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('user', 'List 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' => User::statuses(), 'attribute' => 'status', 'url' => ['ajaxUpdate'], 'type' => 'select', 'display' => "colors", 'editableOptions' => function ($model) {
    return ['source' => User::statuses(), 'value' => $model->status];
}], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => User::roles(), 'attribute' => 'role', 'url' => ['ajaxUpdate'], 'value' => function ($data) {
    return User::getRole($data->role);
}, 'type' => 'select', 'display' => "function(value,sourceData,response){console.log(sourceData);}", 'editableOptions' => ['source' => Yii::$app->user->identity->getEditableRoles(), 'sourceCache' => false]], ['attribute' => 'created_at', 'filter' => false, 'format' => 'datetime'], ['attribute' => 'updated_at', 'filter' => false, 'format' => 'datetime'], ['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(User::$status_colors);
?>
;
        $(this).html(selected[0].text).css("color", colors[value]);
    }
开发者ID:brygom,项目名称:yii2-advanced-template-rbac,代码行数:31,代码来源:user-list.php

示例4:

                    </div>
                    <div class="media-body">
                        <h2 class="mt5"><?php 
echo Html::tag('strong', Html::encode($user->username));
?>
</h2>
                        <p>第 <?php 
echo $user->id;
?>
 位会员</p>
                        <div class="pull-left">
                            <span class="label label-<?php 
echo User::getRole($user->role)['color'];
?>
 role"><?php 
echo User::getRole($user->role)['name'];
?>
</span>
                        </div>
                    </div>
                </div>

                <div class="follow-info row">
                    <div class="col-sm-4 followers" data-login="rei">
                        <a class="counter" href="<?php 
echo Url::to(['/user/default/point', 'username' => $username]);
?>
">
                            <?php 
echo $user->merit ? $user->merit->merit : 0;
?>
开发者ID:grutabow,项目名称:getyii,代码行数:31,代码来源:show.php

示例5: fillUserData

 /**
  * Заполнение данных пользователя.
  *
  * @param User $user
  */
 public function fillUserData(User $user)
 {
     $this->setUserId($user->getId());
     $this->setCompanyId($user->getCompanyId());
     $this->setEmail($user->getEmail());
     $this->setFullName($user->getFullName());
     $this->setRole($user->getRole());
     $this->setStatus($user->getStatus());
     $this->setPhoto($user->getPhoto());
 }
开发者ID:vlamug,项目名称:landing-page-crm,代码行数:15,代码来源:ProfileForm.php


注:本文中的common\models\User::getRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。