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


PHP User::find方法代码示例

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


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

示例1: checkUserSetup

 private static function checkUserSetup()
 {
     if (UserModel::find()->where('id != 1')->count() == 0) {
         $link = Html::a('user module', ['/user/admin/create']);
         \Yii::$app->session->addFlash('warning', "There is no additional user registered, visit {$link} to create an editor.");
     }
 }
开发者ID:7flash,项目名称:app,代码行数:7,代码来源:Helper.php

示例2: actionFollowings

 public function actionFollowings($id)
 {
     $followings = FollowerUsertoUser::find()->where(['follower_user_id' => $id])->all();
     $following_users_ids = ArrayHelper::getColumn($followings, 'followed_user_id');
     $query = User::find()->where(['id' => $following_users_ids]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('index', ['models' => $models, 'caller' => $id, 'callerType' => 'Followings']);
 }
开发者ID:KhemPoudel,项目名称:onlinePaathsaala,代码行数:10,代码来源:FollowController.php

示例3: suggestionsForUsers

 public function suggestionsForUsers()
 {
     $current_user = \Yii::$app->user->identity->getId();
     $followees = FollowerUsertoUser::find()->where(['follower_user_id' => $current_user])->all();
     if (empty($followees)) {
         $users = User::find()->all();
         $scoresOfEachUser = [];
         $models = [];
         foreach ($users as $user) {
             $followRecords = FollowerUsertoUser::find()->where(['followed_user_id' => $user->id]);
             $follows = $followRecords->count();
             $contents = ContentRecord::find()->where(['uploadedBy' => $user->id])->all();
             $contentsIds = ArrayHelper::getColumn($contents, 'id');
             $likeRecords = LikeDislikeContent::find()->where(['content' => $contentsIds, 'likeOrDislike' => 1]);
             $dislikeRecords = LikeDislikeContent::find()->where(['content' => $contentsIds, 'likeOrDislike' => 0]);
             $score = 2 * $follows + $likeRecords->count() - 0.5 * $dislikeRecords->count();
             $scoresOfEachUser[$user->id] = $score;
         }
         arsort($scoresOfEachUser);
         foreach (array_keys($scoresOfEachUser) as $id) {
             $user = User::findOne($id);
             array_push($models, $user);
         }
         return $models;
     } else {
         $targetUsers = [];
         foreach ($followees as $followee) {
             $followersOfFollowee = FollowerUsertoUser::find()->where(['followed_user_id' => $followee->followed_user_id])->all();
             foreach ($followersOfFollowee as $singleFollowerOfFollowee) {
                 $followeesOfFollowerOfFollowees = FollowerUsertoUser::find()->where(['follower_user_id' => $singleFollowerOfFollowee->follower_user_id])->all();
                 foreach ($followeesOfFollowerOfFollowees as $targetUser) {
                     array_push($targetUsers, $targetUser);
                 }
             }
         }
         $followeesIds = ArrayHelper::getColumn($followees, 'followed_user_id');
         $targetUsersIds = ArrayHelper::getColumn($targetUsers, 'followed_user_id');
         $resultUsersIds = array_diff($targetUsersIds, $followeesIds);
         $countOfUsers = array_count_values($resultUsersIds);
         $scoresOfEachUser = [];
         foreach (array_unique($resultUsersIds) as $userId) {
             $followersOfUser = FollowerUsertoUser::find()->where(['followed_user_id' => $userId])->all();
             $followeesOfUser = FollowerUsertoUser::find()->where(['follower_user_id' => $userId])->all();
             $followeesIdsOfUser = ArrayHelper::getColumn($followeesOfUser, 'followed_user_id');
             if (count($followeesOfUser) == 0) {
                 $firstWeight = count($followersOfUser);
             } else {
                 $firstWeight = count($followersOfUser) / count($followeesOfUser);
             }
             $secondWeight = $countOfUsers[$userId];
             $thirdWeight = array_intersect($followeesIdsOfUser, $followeesIds);
             $scoresOfEachUser[$userId] = ($firstWeight + $secondWeight + count($thirdWeight)) / 3;
         }
         $models = [];
         arsort($scoresOfEachUser);
         foreach (array_keys($scoresOfEachUser) as $id) {
             $user = User::findOne($id);
             array_push($models, $user);
         }
         return $models;
     }
 }
开发者ID:KhemPoudel,项目名称:onlinePaathsaala,代码行数:62,代码来源:SiteController.php

示例4:

/* @var $model common\models\PlayerAlbum */
/* @var $form yii\bootstrap\ActiveForm */
?>

<div class="player-album-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->errorSummary($model);
?>

    <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\dektrium\user\models\User::find()->all(), 'id', 'username'), ['prompt' => '']);
?>

    <?php 
echo $form->field($model, 'thumbnail')->widget(Upload::className(), ['url' => ['/file-storage/upload'], 'maxFileSize' => 5000000]);
?>

    <?php 
echo $form->field($model, 'url')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'status')->checkbox();
?>

    <div class="form-group">
开发者ID:buuug7,项目名称:game4039,代码行数:31,代码来源:_form.php

示例5:

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Golfer */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="golfer-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(User::find()->asArray()->all(), 'id', 'username'), ['prompt' => 'Select Yii User']);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 80]);
?>

    <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => 40]);
?>

    <?php 
echo $form->field($model, 'phone')->textInput(['maxlength' => 40]);
?>

    <?php 
开发者ID:kleitz,项目名称:golfleague,代码行数:31,代码来源:_form.php

示例6: date

?>
    </p>

    <?php 
Pjax::begin();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'resizableColumns' => true, 'resizeStorageKey' => Yii::$app->user->id . '-' . date("m"), 'columns' => [['class' => \liyunfang\contextmenu\KartikSerialColumn::className(), 'contextMenu' => true, 'contentOptions' => ['class' => 'kartik-sheet-style'], 'headerOptions' => ['class' => 'kartik-sheet-style'], 'urlCreator' => function ($action, $model, $key, $index) {
    if ('update' == $action) {
        return Yii::$app->getUrlManager()->createUrl(['/log/update', 'id' => $model->id]);
    }
    if ('view' == $action) {
        return Yii::$app->getUrlManager()->createUrl(['/log/view', 'id' => $model->id]);
    }
    return '#';
}], ['class' => '\\kartik\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'text-info text-center'], 'contentOptions' => ['class' => 'text-center', 'width' => '5%'], 'checkboxOptions' => function ($model, $key, $index, $column) {
    return ['value' => $model->id];
}], ['attribute' => 'user_name', 'contentOptions' => ['width' => '15%'], 'filter' => \kartik\widgets\Select2::widget(['model' => $searchModel, 'attribute' => 'user_name', 'data' => \yii\helpers\ArrayHelper::map(\dektrium\user\models\User::find()->all(), 'email', 'email'), 'pluginOptions' => ['allowClear' => true], 'options' => ['prompt' => '---请选择需要筛选的用户---']])], ['attribute' => 'user_ip', 'contentOptions' => ['width' => '10%']], ['attribute' => 'controller', 'contentOptions' => ['width' => '10%']], ['attribute' => 'action', 'contentOptions' => ['width' => '10%']], ['attribute' => 'result', 'contentOptions' => ['width' => '20%'], 'content' => function ($model, $key, $index, $column) {
    $result = \yii\helpers\Json::decode($model->result);
    //$classname = ucfirst($model->controller);
    $classname = $model->model;
    $dirtyAttributes = $result['dirtyAttrs'];
    $contents = '';
    if (count($dirtyAttributes)) {
        $contents .= '<ol>';
        foreach ($dirtyAttributes as $key => $val) {
            $contents .= "<li>" . (new $classname())->getAttributeLabel($key) . ":{$val}</li>";
        }
        $contents .= '</ol>';
    }
    return $contents;
}], ['attribute' => 'created_at', 'format' => 'datetime', 'contentOptions' => ['width' => '15%']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['width' => '10%'], 'buttons' => ['update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Yii::$app->urlManager->createUrl(['log/view', 'id' => $model->id, 'edit' => 't']), ['title' => Yii::t('yii', 'Edit')]);
开发者ID:tqsq2005,项目名称:Yii2adv,代码行数:31,代码来源:index.php

示例7: getUsername

 public function getUsername()
 {
     return \dektrium\user\models\User::find($this->user_id)->username;
 }
开发者ID:pc-brainy,项目名称:blitz,代码行数:4,代码来源:Roles.php

示例8:

use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use kartik\datecontrol\DateControl;
/**
 * @var yii\web\View $this
 * @var common\models\Events $model
 * @var yii\widgets\ActiveForm $form
 */
?>

<div class="events-form">

    <?php 
$form = ActiveForm::begin(['id' => 'events-form', 'type' => ActiveForm::TYPE_HORIZONTAL, 'formConfig' => ['labelSpan' => 3]]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['user_id' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\Select2', 'options' => ['data' => \yii\helpers\ArrayHelper::map(\dektrium\user\models\User::find()->all(), 'id', 'username'), 'value' => $model->isNewRecord ? Yii::$app->user->identity->getId() : $model->user_id, 'options' => ['prompt' => '---请选择事件关联的用户---'], 'addon' => ['append' => ['content' => Html::button(\kartik\helpers\Html::icon('fa fa-user-plus', [], ''), ['class' => 'btn btn-primary', 'title' => '请选择事件关联的用户', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom']), 'asButton' => true]], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 3]]], 'title' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter 事件标题...', 'maxlength' => 100]], 'data' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Enter 事件内容...', 'rows' => 6]], 'time' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter 触发事件次数...']]]]);
?>
    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-9">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Save') : Yii::t('app', 'Update'), ['id' => 'btn-modal-footer', 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        </div>
    </div>
    <?php 
//echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Save') : Yii::t('app', 'Update'), ['id' => 'btn-modal-footer','class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
ActiveForm::end();
?>
开发者ID:tqsq2005,项目名称:Yii2adv,代码行数:30,代码来源:_form.php

示例9:

                            </div>
                            <!--//Row-->
                            <div class="row">
                                <div class="col-md-4">
                                    <?php 
echo $form->field($model, 'status')->widget(Select2::classname(), ['data' => $model->getItemStatus(), 'options' => ['placeholder' => 'สถานะอุปกรณ์...'], 'pluginOptions' => ['allowClear' => true]]);
?>
                                </div>
                                <div class="col-md-4">
                                    <?php 
echo $form->field($model, 'depart')->widget(Select2::classname(), ['data' => ArrayHelper::map(Section::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'หน่วยงาน/ฝ่าย/แผนก...'], 'pluginOptions' => ['allowClear' => true]]);
?>
                                </div>
                                <div class="col-md-4">
                                    <?php 
echo $form->field($model, 'mod')->widget(Select2::classname(), ['data' => ArrayHelper::map(User::find()->all(), 'id', 'username'), 'options' => ['placeholder' => 'ผู้รับผิดชอบ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-12">
                                    <?php 
echo $form->field($model, 'income')->widget(Select2::classname(), ['data' => $model->getItemIncome(), 'options' => ['placeholder' => 'วิธีการได้มา...'], 'pluginOptions' => ['allowClear' => true]]);
?>
                                </div>
                            </div>
                            <!--//Row-->
                            <div class="row">
                                <div class="col-md-12">
                                    <?php 
开发者ID:poykub,项目名称:wph,代码行数:31,代码来源:_form.php

示例10:

use dektrium\user\models\User;
use kartik\widgets\Select2;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model backend\models\Roles */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="roles-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'user_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(User::find()->orderby('username', 'ASC')->all(), 'id', 'username'), 'options' => ['placeholder' => Yii::t('app', 'Select an user') . '...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'role_type_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\backend\models\RoleTypes::find()->orderby('id', 'ASC')->all(), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Select a role') . '...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
开发者ID:pc-brainy,项目名称:blitz,代码行数:31,代码来源:_form.php

示例11:

use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\RoleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Roles');
$this->params['breadcrumbs'][] = $this->title;
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Roles'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    
<div class="roles-index" style="margin-top: 30px;">

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


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'user_id', 'value' => 'user.username', 'filter' => yii\helpers\ArrayHelper::map(\dektrium\user\models\User::find()->orderBy('username', 'ASC')->all(), 'id', 'username')], ['attribute' => 'role_type_id', 'value' => 'roleType.name', 'filter' => yii\helpers\ArrayHelper::map(\backend\models\RoleTypes::find()->orderBy('name', 'ASC')->all(), 'id', 'name')], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

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

示例12: actionStudent

 public function actionStudent()
 {
     Url::remember('', 'actions-redirect');
     $query = User::find()->where(['category_id' => 1]);
     $searchModel = Yii::createObject(UserSearch::className());
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $this->render('student', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
开发者ID:Kolya-an,项目名称:wemamas,代码行数:8,代码来源:AdminController.php

示例13: getUsersSelect2

 /**
  * Return array for User Select2 with current user selected
  * @param $userid
  * @param $username
  * @return array
  */
 public function getUsersSelect2($userid, $username)
 {
     $users = User::find()->select(['id', 'username'])->where(['blocked_at' => null, 'unconfirmed_email' => null])->andWhere(['!=', 'id', $userid])->all();
     $array[$userid] = ucwords($username);
     foreach ($users as $user) {
         $array[$user['id']] = ucwords($user['username']);
     }
     return $array;
 }
开发者ID:cinghie,项目名称:yii2-articles,代码行数:15,代码来源:Articles.php

示例14: getUser

 protected function getUser($username)
 {
     return \dektrium\user\models\User::find()->where(['username' => $username])->one();
 }
开发者ID:pc-brainy,项目名称:blitz,代码行数:4,代码来源:SecurityController.php

示例15: function

?>
    

<?php 
$toolbars = [['content' => Html::button('<i class="fa fa-question-circle"></i> 操作指引', ['type' => 'button', 'title' => '操作指引-' . $this->title, 'class' => 'btn btn-warning', 'id' => 'helpButton']) . '&nbsp;&nbsp;' . Html::button('<i class="fa fa-history"></i> 恢复记录', ['type' => 'button', 'title' => '恢复记录-' . $this->title, 'class' => 'btn btn-success', 'id' => 'retrieveSelected']) . '&nbsp;&nbsp;' . Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['event/history', 'p_reset' => true], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid']) . ' '], ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'], '{export}'];
$panels = ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i>  ' . $this->title . '</h3>', 'before' => '<div style="padding-top: 7px;"><em>* 右边可以导出各种格式并对表格进行个性化设置</em></div>'];
$columns = [['class' => '\\kartik\\grid\\CheckboxColumn', 'checkboxOptions' => ['class' => 'simple'], 'rowSelectedClass' => GridView::TYPE_SUCCESS, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'width' => '5%'], ['class' => 'kartik\\grid\\SerialColumn', 'order' => DynaGrid::ORDER_FIX_LEFT, 'width' => '5%'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '5%', 'value' => function ($model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
    //return Yii::$app->controller->renderPartial('_details', ['model'=>$model]);
    return $model->old_value;
}, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true], ['attribute' => 'model_id', 'header' => '事件ID', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'hAlign' => 'center', 'value' => function ($model, $key, $index, $column) {
    return $model->model_id ? Html::a($model->model_id, ['audit/entry/view', 'id' => $model->entry_id], ['target' => '_blank']) : '';
}, 'format' => 'raw', 'width' => '6%'], ['attribute' => 'user_id', 'header' => '操作人员', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'hAlign' => 'center', 'value' => function ($model, $key, $index, $column) {
    return \dektrium\user\models\User::findOne($model->user_id)->username;
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\dektrium\user\models\User::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '操作人员'], 'format' => 'raw', 'width' => '10%'], ['attribute' => 'created', 'header' => '删除时间', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'hAlign' => 'center', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd', 'todayHighlight' => true, 'autoclose' => true]], 'format' => 'datetime', 'width' => '15%'], ['attribute' => 'old_value', 'header' => '删除内容', 'headerOptions' => ['class' => 'text-primary'], 'vAlign' => 'middle', 'format' => 'raw', 'width' => '54%', 'content' => function ($model, $key, $index, $column) {
    return "<div class='event_old_value'>{$model->old_value}</div>";
}]];
$dynagrid = DynaGrid::begin(['id' => 'event-history-grid', 'columns' => $columns, 'theme' => 'panel-primary', 'showPersonalize' => true, 'storage' => 'db', 'allowSortSetting' => true, 'gridOptions' => ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showPageSummary' => true, 'floatHeader' => true, 'pjax' => true, 'panel' => $panels, 'toolbar' => $toolbars, 'hover' => true], 'options' => ['id' => 'Event-history-' . Yii::$app->user->identity->id]]);
DynaGrid::end();
?>
 </div>
<?php 
\common\widgets\JsBlock::begin();
?>
    <script type="text/javascript">
        $(function(){
            /*var content = "<ul>恢复操作指引<li><font color='red'>删除内容</font>中输入内容筛选</li><li>点击复选框选中需要恢复的记录</li><li>点击按钮恢复记录</li></ul>";
            layer.msg(content, {
                shift: 0,
                icon: 6,
开发者ID:tqsq2005,项目名称:Yii2adv,代码行数:31,代码来源:history.php


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