/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Role::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Role::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['RoleId' => $this->RoleId, 'createdDate' => $this->createdDate, 'updatedDate' => $this->updatedDate]); $query->andFilterWhere(['like', 'RoleName', $this->RoleName])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'ipAddress', $this->ipAddress]); return $dataProvider; }
/** * Lists all User models. * @return mixed */ public function actionIndex() { // $dataProviderUser = new ActiveDataProvider([ // 'query' => User::find(), // ]); $query = new \yii\db\Query(); $query = \backend\models\Role::find()->select(['name', 'description'])->asArray()->where(['`type`' => '1'])->orderBy('name'); $dataProviderRole = new ActiveDataProvider(['query' => $query]); $searchModel = new \backend\models\UserSearch(); $dataProviderUser = $searchModel->search(Yii::$app->request->queryParams); // return $this->render('index', [ // 'searchModel' => $searchModel, // 'dataProvider' => $dataProvider, // ]); return $this->render('index', ['dataProviderUser' => $dataProviderUser, 'dataProviderRole' => $dataProviderRole]); }
/** * @getRoleList */ public function getRoleList() { $droptions = Role::find()->asArray()->all(); return Arrayhelper::map($droptions, 'role_value', 'role_name'); }
public static function isRoleNameValid($role_name) { $role = Role::find('role_name')->where(['role_name' => $role_name])->one(); return isset($role->role_name) ? true : false; }
/** * get list of roles for dropdown * */ public function getRoleList() { $droplist = Role::find()->asArray()->all(); return ArrayHelper::map($droplist, 'id', 'name'); }
/** * Finds the Role model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Role the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Role::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getRoleList() { $droptions = Role::find()->asArray()->all(); return Arrayhelper::map($droptions, 'id', 'name'); }
echo $form->field($model, 'password')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'status')->checkBox(); ?> <div class="form-group field-user-email required"> <label class="control-label" for="auth_item">Role</label> <?php echo Html::activeDropDownList($model, 'auth_item', ArrayHelper::map(\backend\models\Role::findAll(['type' => 1]), 'name', 'name'), ['class' => 'form-control']); ?> <div class="help-block"></div> </div> <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(); ?>
echo $form->field($model, 'email'); ?> <?php echo $form->field($userData, 'first_name'); ?> <?php echo $form->field($userData, 'last_name'); ?> <?php if ($model->isNewRecord) { echo $form->field($model, 'password')->passwordInput(); echo $form->field($model, 'password_repeat')->passwordInput(); } ?> <?php echo $form->field($model, 'role')->dropDownList(Role::getChildren(), ['prompt' => Yii::t('general', 'Please select')]); ?> <? //= $form->field($hotelMapping, 'hotel_id')->dropDownList(Hotel::getMap(), ['prompt' => Yii::t('general', 'Please select')]) ?> <div class="form-group"> <div class="col-md-6"><?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'col-md-12 btn btn-success' : 'col-md-12 btn btn-primary']); ?> </div> <div class="col-md-offset-6"><?php echo Html::a('Change password', Yii::$app->urlManager->createUrl(['/user/change-password', 'id' => $model->id]), ['class' => 'col-md-12 btn btn-danger']); ?> </div> </div> <?php
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'User Details'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="user-details-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php // echo Html::a('Create User Details', ['create'], ['class' => 'btn btn-success']) ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['f_name', 'l_name', 'p_phone', 's_phone', 'p_email', 's_email', 's_question', 's_answer', ['label' => 'role', 'value' => function ($model) { return \backend\models\Role::find()->andWhere(['value' => $model->role])->one()->name; }], 'created_at:datetime', 'updated_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/** * Finds the Role model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Role the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Role::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('Запрашиваемая страница не найдена.'); } }