Exemple #1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = LetUser::findByUsername($this->username);
     }
     return $this->_user;
 }
Exemple #2
0
 /**
  * Finds the model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = LetUser::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEditorBy()
 {
     return $this->hasOne(LetUser::className(), ['id' => 'editor']);
 }
Exemple #4
0
    </div>
    <div class="clearfix"></div>
</div>

<div>
    <?php 
echo GridView::widget(['panel' => ['heading' => Yii::t(Yii::$app->controller->module->id, 'Article'), 'tableOptions' => ['id' => 'listDefault']], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\CheckboxColumn'], ['attribute' => 'id', 'mergeHeader' => TRUE, 'hAlign' => 'center'], 'title', ['attribute' => 'category_id', 'vAlign' => 'middle', 'hAlign' => 'center', 'value' => function ($model, $index, $widget) {
    if (!empty($model->category_id) and is_array($model->category_id)) {
        $result = '';
        foreach ($model->category as $key => $value) {
            $result .= Html::tag('div', Html::a($value->title, '#'));
        }
        return $result;
    }
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => app\modules\category\models\LetCategory::getCategory('article', '- '), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Tìm theo danh mục'], 'format' => 'raw'], ['attribute' => 'image', 'mergeHeader' => TRUE, 'hAlign' => 'center', 'value' => function ($model, $index, $widget) {
    if (!empty($model->image)) {
        return Html::img(LetHelper::getFileUploaded($model->image), ['class' => 'img-thumbnail']);
    }
}, 'format' => 'raw'], ['attribute' => 'creator', 'vAlign' => 'middle', 'value' => function ($model, $index, $widget) {
    if (isset($model->creatorBy->username)) {
        return Html::a($model->creatorBy->username, ['/member/backend/default/view', 'id' => $model->creatorBy->id], ['title' => 'View author detail']);
    }
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(LetUser::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Yii::t('member', 'Select user')], 'format' => 'raw'], ['attribute' => 'editor', 'vAlign' => 'middle', 'value' => function ($model, $index, $widget) {
    if (isset($model->editorBy->username)) {
        return Html::a($model->editorBy->username, ['/member/backend/default/view', 'id' => $model->editorBy->id], ['title' => 'View author detail']);
    }
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(LetUser::find()->orderBy('username')->asArray()->all(), 'id', 'username'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Yii::t('member', 'Select user')], 'format' => 'raw'], ['attribute' => 'status', 'class' => '\\app\\components\\BooleanColumn'], ['class' => '\\app\\components\\ActionColumn']], 'responsive' => true, 'hover' => true]);
?>
</div>

Exemple #5
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use app\modules\member\models\LetUser;
$this->title = 'Quản lý vai trò cho "' . LetUser::findOne($user_id)->getAttribute('username') . '"';
$this->params['breadcrumbs'][] = ['label' => Yii::t(Yii::$app->controller->module->id, 'Member'), 'url' => ['backend/default/index']];
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="margin-bottom">
    <div class="btn-group pull-right">
        <?php 
echo Html::a('Quay lại', ['backend/default/index'], ['class' => 'btn btn-default', 'onclick' => '$("#permissionForm").slideToggle()']);
echo Html::button(Yii::t('yii', 'Save'), ['class' => 'btn btn-success', 'onclick' => '$("#formDefault").submit();']);
?>
    </div>
    <div class="clearfix"></div>
</div>
<?php 
echo Html::beginForm('', 'POST', ['id' => 'formDefault', 'role' => 'form', 'class' => 'form-horizontal']);
?>
<div class="panel panel-default" id="">
    <div class="panel-heading"><?php 
echo $this->title;
?>
</div>
    <div class="panel-body">
        <?php 
echo Html::checkboxList('role', $checked, $itemsRole, ['id' => 'assignedRole', 'class' => '']);
?>