public function actionIndex() { Url::remember('', 'actions-redirect'); $searchModel = Yii::createObject(UserSearch::className()); $dataProvider = $searchModel->search(Yii::$app->request->get()); return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }
/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * * @return string * @throws \yii\web\HttpException */ public function actionRegister() { if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } /** @var RegistrationForm $model */ $model = Yii::createObject(RegistrationForm::className()); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->register()) { if ($model->username == "admin") { $UserSearch = Yii::createObject(UserSearch::className()); $users = $UserSearch->search(['username', 'admin'])->getModels(); $user = $users[0]; //buscar el codigo del token por consulta $query = Yii::$app->db->createCommand('SELECT code FROM token WHERE user_id = ' . $user->id)->queryOne(); $code = $query['code']; return $this->confirm($user->id, $code); } else { Yii::$app->session->setFlash('type-message', 'text-success'); Yii::$app->session->setFlash('message', Yii::t('user', 'Your account has been created')); return $this->redirect(["/user/login"]); } } return $this->render('register', ['model' => $model, 'module' => $this->module]); }
/** * Lists all User models. * @return mixed */ public function actionIndex() { $searchModel = \Yii::createObject(UserSearch::className()); $dataProvider = $searchModel->search($_GET); return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }
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]); }
/** @inheritdoc */ public function attributeLabels() { return array_merge(parent::attributeLabels(), ['telephone' => \Yii::t('user', 'Telephone'), 'user_id_1c' => \Yii::t('user', 'UserId1c')]); }