本文整理汇总了PHP中backend\models\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$this->layout = false;
if (\Yii::$app->request->isAjax) {
$user = new User();
$data = \Yii::$app->request->post();
$userInfo = $user->getFindUser(['name' => $data['name']]);
$pass = md5(md5($data['password']));
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
//将响应数据转json格式
if (!$userInfo || $userInfo['password'] != $pass) {
//验证用户登录信息
return ['msg' => '用户名或密码错误', 'status' => 0];
} else {
if ($member = \common\models\User::getInstance()->getUserByPhone($userInfo['phone'])) {
$userInfo['member'] = $member;
}
$auth = \Yii::$app->authManager;
$userRole = $auth->getAssignments($userInfo['id']);
$role = "";
foreach ($userRole as $k => $v) {
if ($k == 'admin') {
$role = "admin";
break;
}
$role .= "," . $k;
}
$userInfo['role'] = $role;
$user->setUserSession($userInfo);
//设置Session
return ['msg' => '登录成功', 'status' => 1];
}
}
return $this->render('index.html');
}
开发者ID:xswolf,项目名称:baihey,代码行数:35,代码来源:LoginController.php
示例2: reg
public function reg()
{
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->status = $this->status;
$user->setPassword($this->password);
$user->generateAuthKey();
return $user->save() ? $user : null;
}
开发者ID:GalkinDmitriy,项目名称:evalotta,代码行数:10,代码来源:RegForm.php
示例3: signup
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
}
return null;
}
开发者ID:xishuophp,项目名称:vipoa,代码行数:19,代码来源:SignupForm.php
示例4: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByUsername($this->username);
}
return $this->_user;
}
开发者ID:jia253,项目名称:centosYii2,代码行数:12,代码来源:SiteLoginForm.php
示例5: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->user === false) {
$this->user = User::find()->andWhere(['or', ['username' => $this->username], ['email' => $this->username]])->one();
}
return $this->user;
}
开发者ID:buuug7,项目名称:game4039,代码行数:12,代码来源:LoginForm.php
示例6: fire
/**
* Execute the console command.
* @throws Exception
*/
public function fire()
{
$login = $this->argument('login');
if ($this->rainlab) {
$rainlab = (bool) $this->option('rainlab');
} else {
$rainlab = false;
}
if ($rainlab) {
$user = \RainLab\User\Models\User::where('email', '=', $login)->orWhere('username', '=', $login)->first();
} else {
$user = User::whereLogin($login)->first();
}
if (!$user) {
return $this->error('User not found');
}
$password = $this->option('password');
if ($rainlab) {
$login = 'RainLab.User => ' . $login;
} else {
$login = 'Backend.User => ' . $login;
}
if ($password == null) {
$password = $this->ask('Set password for ' . $login . ' (or press Enter to skip)');
}
if ($password == null) {
$password = Str::random(5);
}
$user->update(['password' => $password, 'password_confirmation' => $password]);
$message = "\n -> new password for " . $login . ": ";
$this->comment($message . $password);
return;
}
开发者ID:grohman,项目名称:oc-idwidgets,代码行数:37,代码来源:UserPassword.php
示例7: actionPassword
public function actionPassword()
{
$model = User::findOne(Yii::$app->user->id);
$data = Yii::$app->request->post('User');
if (count($data)) {
if (isset($data['password'])) {
if ($model->validateName($data['username'])) {
if ($model->validatePassword($data['password_old']) && $model->validateName($data['username_old'])) {
$model->setAttributes($data);
$model->setPassword($model->password);
if ($model->save()) {
Yii::$app->session->setFlash('success', '密码修改成功');
} else {
Yii::$app->session->setFlash('danger', '密码修改失败');
}
} else {
Yii::$app->session->setFlash('danger', '原密码有误, 请输入正确的原密码');
}
} else {
Yii::$app->session->setFlash('danger', '用户名已存在请重试');
}
}
}
$result['model'] = $model;
return $this->render('password', $result);
}
开发者ID:cindyming,项目名称:yii-advance,代码行数:26,代码来源:SystemController.php
示例8: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = User::findByUsername($this->username);
}
return $this->_user;
}
开发者ID:cindyming,项目名称:yii-advance,代码行数:12,代码来源:LoginForm.php
示例9: actionSave
public function actionSave()
{
$this->_setJSONFormat(Yii::$app);
$request = Yii::$app->request;
$data = $request->post();
$code = '1';
if (!empty($data['_id'])) {
$product = Product::findOne($data['_id']['$id']);
$data['updatedAt'] = new \MongoDate();
$code = '2';
}
if (empty($product)) {
$product = new Product();
$accessToken = Token::getToken();
$user = User::findOne(['_id' => $accessToken->userId]);
$data['accountId'] = $this->getAccountId();
$data['creator'] = $user->name;
$data['createdAt'] = new \MongoDate();
$data['isDeleted'] = false;
}
if (!empty($product->accountId)) {
unset($data['accountId']);
}
$product->attributes = $data;
$product->save();
return ['code' => $code];
}
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:27,代码来源:ProductController.php
示例10: actionSave
public function actionSave()
{
$accountId = $this->getAccountId();
$request = Yii::$app->request;
$operatorId = $request->post('operatorId', '');
$sampleId = $request->post('sampleId', '');
$name = $request->post('name', '');
$quantity = $request->post('quantity', '');
$imgUrl = $request->post('imgUrl', '');
$operator = User::find()->where(['_id' => $operatorId])->one();
if ($operator === null) {
return ['code' => 1309, 'msg' => 'not login'];
}
if ($name == '') {
return ['code' => 1300, 'msg' => 'name not get'];
}
if ($quantity == '') {
return ['code' => 1300, 'msg' => 'quantity not get'];
}
$sample = Sample::find()->where(['_id' => $sampleId])->one();
if ($sampleId == '' || $sample == null) {
$sample = new Sample();
$sample->usedNumber = 0;
}
$sample->name = $name;
$sample->quantity = $quantity;
$sample->operator = $operator->name;
$sample->imgUrl = $imgUrl;
$sample->accountId = $accountId;
$sample->save();
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return ['code' => 200, 'msg' => 'OK'];
}
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:33,代码来源:SampleController.php
示例11: actionEdituser
public function actionEdituser()
{
$req = Yii::$app->request;
//创建一个请求对象
$form = new UserForm();
$form->setScenario('update');
$id = trim($req->get('id'));
if (!is_numeric($id) || $id == 0) {
$this->redirect(Variable::$userMange_url);
return;
}
//修改
if ($form->load($req->post()) && $form->validate()) {
$isSuccess = (new User())->updateCusetomer($id, $form->realName, $form->nickName, $form->password, $form->email, $form->mobile, $form->userType, $form->userStatus, $form->frozenReason, $form->comeFrom);
if ($isSuccess) {
$form->addError('', '资料更新成功');
} else {
$form->addError('', '资料更新失败');
}
}
$userModel = User::findOne($id);
$form->realName = $userModel->realName;
$form->nickName = $userModel->nickName;
$form->password = $userModel->password;
$form->email = $userModel->email;
$form->mobile = $userModel->mobile;
$form->userType = $userModel->userType;
$form->userStatus = $userModel->userStatus;
$form->frozenReason = $userModel->frozenReason;
$form->comeFrom = $userModel->comeFrom;
return $this->render(Variable::$editUser_view, ['model' => $form, 'userModel' => $userModel]);
}
开发者ID:jaybril,项目名称:www.mimgpotea.com,代码行数:32,代码来源:UsermangerController.php
示例12: actionStockPedidos
public function actionStockPedidos($idComercio, $idRutaDiaria)
{
$rutaDiaria = RutaDiaria::find()->where(['id' => $idRutaDiaria])->one();
$usuario = User::find()->where(['id' => $rutaDiaria->id_usuario])->one();
$rutaDiariaComercio = $this->findRutaDiariaComercio($idComercio, $idRutaDiaria);
$datosGrillaStock = [];
$datosGrillaPedidos = [];
$i = 0;
if ($rutaDiariaComercio->getStocks()->count() > 0) {
$datosStock = $this->findStockComercio($rutaDiariaComercio->id);
foreach ($datosStock as $stock) {
$nombreProducto = nombreProducto($stock->id_producto);
$datosGrillaStock[$i] = ['tipo' => Yii::t('core', 'Stock'), 'producto' => $nombreProducto, 'cantidad' => $stock->cantidad];
$i++;
}
}
$i = 0;
if ($rutaDiariaComercio->getPedidos()->count() > 0) {
$datosPedidos = $this->findPedidosComercio($rutaDiariaComercio->id);
foreach ($datosPedidos as $pedido) {
$nombrePedido = nombreProducto($pedido->id_producto);
$datosGrillaPedidos[$i] = ['tipo' => Yii::t('core', 'Order'), 'producto' => $nombrePedido, 'cantidad' => $pedido->cantidad];
$i++;
}
}
return $this->render('stockPedidos', ['model' => $rutaDiariaComercio, 'datosGrillaStock' => $datosGrillaStock, 'datosGrillaPedidos' => $datosGrillaPedidos, 'fecha' => $rutaDiaria->fecha, 'usuario' => $usuario->username, 'ruta' => $rutaDiaria->id]);
}
开发者ID:apmauj,项目名称:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代码行数:27,代码来源:RutaDiariaController.php
示例13: actionCreate
/**
* The first step of creating page
* Use the createBasic scenario
**/
public function actionCreate()
{
$params = $this->getParams();
$accesstoken = $this->getAccessToken();
$token = Token::getToken($accesstoken);
$page = new Page(['scenario' => 'createBasic']);
$page->attributes = $params;
$page->_id = new \MongoId();
$page->accountId = $token->accountId;
$userId = $token->userId;
$user = User::findByPk($userId);
$page->creator = ['id' => $userId, 'name' => $user->name];
$page->url = Yii::$app->request->hostinfo . '/msite/page/' . $page->_id;
$shortUrl = Yii::$app->urlService->shortenUrl($page->url);
$page->shortUrl = $shortUrl['Short'];
if ($page->validate()) {
// all inputs are valid
if ($page->save()) {
return $page;
} else {
throw new ServerErrorHttpException(Yii::t('common', 'save_fail'));
}
} else {
// valid fail, return errors
$errors = array_keys($page->errors);
throw new InvalidParameterException([$errors[0] => Yii::t("microSite", $errors[0] . '_field_not_empty')]);
}
}
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:32,代码来源:PageController.php
示例14: setStatus
public function setStatus($id, $status = 1)
{
if (!in_array($status, [0, 1]) || $id == 1) {
return false;
}
return User::updateAll(['status' => $status], 'id = :id', [':id' => $id]);
}
开发者ID:wordnews,项目名称:wei_shop,代码行数:7,代码来源:User.php
示例15: actionPedido
public function actionPedido()
{
$params = Yii::$app->getRequest()->post();
$usuario = User::findIdentityByAccessToken($params['muli_token']);
$arrayProductos = $params['productos'];
$valid = false;
foreach ($arrayProductos as $productos) {
$rutaDiaria = RutaDiaria::find()->where(['id_usuario' => $usuario->id])->andWhere(['fecha' => date('Y-m-d')])->one();
$rutaDiariaComercio = RutaDiariaComercio::find()->where(['id_comercio' => $params['id_comercio']])->andWhere(['id_ruta_diaria' => $rutaDiaria->id])->one();
$pedidoIdProd = Pedido::find()->where(['id_producto' => $productos['id_producto']])->andWhere(['id_ruta_diaria_com' => $rutaDiariaComercio->id])->one();
if ($pedidoIdProd != null) {
$pedido = $pedidoIdProd;
$pedido->setAttribute('cantidad', $productos['cant']);
} else {
$pedido = new Pedido();
$pedido->setAttribute('id_producto', $productos['id_producto']);
$pedido->setAttribute('id_ruta_diaria_com', $rutaDiariaComercio->id);
$pedido->setAttribute('cantidad', $productos['cant']);
}
if ($pedido->cantidad != 0) {
if ($pedido->validate() && $pedido->save()) {
$valid = true;
} else {
throw new BadRequestHttpException(Yii::t('mobile', 'Failed to save route with id: ' . $rutaDiariaComercio->id . ''));
}
} else {
if ($pedido->validate()) {
$valid = true;
} else {
throw new BadRequestHttpException(Yii::t('mobile', 'Failed to save route with id: ' . $rutaDiariaComercio->id . ''));
}
}
}
return $valid;
}
开发者ID:apmauj,项目名称:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代码行数:35,代码来源:PedidoController.php
示例16: getUser
/**
* 获取用户对象
*/
public function getUser()
{
if ($this->getIsNewRecord()) {
return [];
}
$data = User::findOne($this->getAttribute('uid'));
return $data;
}
开发者ID:nihao5,项目名称:huanglong,代码行数:11,代码来源:Order.php
示例17: actionShowTo
public function actionShowTo()
{
\Yii::$app->response->format = Response::FORMAT_JSON;
$id = $_POST['id'];
$todoList = User::find()->where(['id' => $id])->with('todos')->asArray()->one();
//print_r($done);
return $todoList;
}
开发者ID:Hardronox,项目名称:first-project,代码行数:8,代码来源:UserApiController.php
示例18: findModel
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = User::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
开发者ID:djc1103617718,项目名称:WangYi,代码行数:15,代码来源:UserManagerController.php
示例19: loginAdmin
public function loginAdmin()
{
if ($this->validate() && (User::isAdmin($this->username) || User::isSuperAdmin($this->username))) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
} else {
return false;
}
}
开发者ID:baobkath,项目名称:lenguage_center,代码行数:8,代码来源:BUser.php
示例20: actionUserList
public function actionUserList($id = 0)
{
if ($id) {
return User::findOne($id)->username;
} else {
return $this->_list(new User(), 'user-list');
}
}
开发者ID:nisnaker,项目名称:yii2-template,代码行数:8,代码来源:RbacController.php
注:本文中的backend\models\User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论