/** * 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'); }
public static function getRoleList() { $droptions = Role::find()->asArray()->all(); return Arrayhelper::map($droptions, 'id', 'name'); }
<?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>
/** * Lists all Role models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Role::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }