本文整理汇总了PHP中backend\models\User::className方法的典型用法代码示例。如果您正苦于以下问题:PHP User::className方法的具体用法?PHP User::className怎么用?PHP User::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend\models\User
的用法示例。
在下文中一共展示了User::className方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Registers a new user account. If registration was successful it will set flash message.
*
* @return bool
*/
public function register()
{
if (!$this->validate()) {
return false;
}
/** @var User $user */
$user = Yii::createObject(User::className());
$user->setScenario('register');
$this->loadAttributes($user);
if (!$user->register()) {
return false;
}
Yii::$app->session->setFlash('info', Yii::t('user', 'Your account has been created and a message with further instructions has been sent to your email'));
return true;
}
示例2: actionConnect
/**
* Displays page where user can create new account that will be connected to social account.
*
* @param string $code
*
* @return string
* @throws NotFoundHttpException
*/
public function actionConnect($code)
{
$account = $this->finder->findAccount()->byCode($code)->one();
if ($account === null || $account->getIsConnected()) {
throw new NotFoundHttpException();
}
/** @var User $user */
$user = Yii::createObject(['class' => User::className(), 'scenario' => 'connect', 'username' => $account->username, 'email' => $account->email]);
if ($user->load(Yii::$app->request->post()) && $user->create()) {
$account->connect($user);
return $this->render('/message', ['title' => Yii::t('user', 'Your account has been created'), 'module' => $this->module]);
// Yii::$app->user->login($user, $this->module->rememberFor);
// return $this->goBack();
}
return $this->render('connect', ['model' => $user, 'account' => $account]);
}
示例3: actionCreate
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$user = Yii::createObject(['class' => User::className(), 'scenario' => 'create']);
if ($user->load(Yii::$app->request->post())) {
/* $coordenadas = sysconfigs::getCoordinates($user->direccion);
$user->latitud = $coordenadas['latitud'];
$user->longitud = $coordenadas['longitud'];*/
//generamos password
$user->password = $user->password == null ? Password::generate(8) : $user->password;
if ($user->save()) {
$user->mailer->sendWelcomeMessage($user, null);
return $this->redirect(['update', 'id' => $user->id]);
} else {
return $this->render('create', ['user' => $user]);
}
} else {
return $this->render('create', ['user' => $user]);
}
}
示例4: rules
public function rules()
{
return [[['username', 'email', 'password'], 'filter', 'filter' => 'trim'], [['username', 'email', 'password'], 'required'], ['username', 'string', 'min' => 2, 'max' => 255], ['password', 'string', 'min' => 6, 'max' => 255], ['username', 'unique', 'targetClass' => User::className(), 'message' => 'Это имя уже занято.'], ['email', 'email'], ['email', 'unique', 'targetClass' => User::className(), 'message' => 'Эта почта уже занята.'], ['status', 'default', 'value' => User::STATUS_ACTIVE, 'on' => 'default'], ['status', 'in', 'range' => [User::STATUS_NOT_ACTIVE, User::STATUS_ACTIVE]]];
}
示例5: getUser
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
示例6: getUser
public function getUser()
{
return $this->hasMany(User::className(), ['level_id' => 'level_id']);
}
示例7: dirname
<?php
use backend\models\User;
$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'app-backend', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'backend\\controllers', 'aliases' => ['@file_view_dir' => '@backend/files'], 'bootstrap' => ['log'], 'modules' => [], 'components' => ['user' => ['identityClass' => User::className(), 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error']], 'params' => $params];
示例8: getAuthor
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthor()
{
return $this->hasOne(User::className(), ['id' => 'author_id']);
}
示例9: getUsers
/**
* @return \yii\db\ActiveQuery
*/
public function getUsers()
{
return $this->hasMany(User::className(), ['role_id' => 'role_value']);
}
示例10: getUsers
/**
* @return \yii\db\ActiveQuery
*/
public function getUsers()
{
return $this->hasMany(User::className(), ['attendee_id' => 'id']);
}
示例11: getAddress
public function getAddress()
{
return $this->hasOne(User::className(), ['id' => 'addressId']);
}
示例12: getIdUsuario
/**
* @return \yii\db\ActiveQuery
*/
public function getIdUsuario()
{
return $this->hasOne(User::className(), ['id' => 'id_usuario']);
}
示例13: getCreatedBy
/**
* @return \yii\db\ActiveQuery
*/
public function getCreatedBy()
{
return $this->hasOne(User::className(), ['id' => 'created_by']);
}
示例14: getUsername0
/**
* @return \yii\db\ActiveQuery
*/
public function getUsername0()
{
return $this->hasOne(User::className(), ['username' => 'username']);
}
示例15: getUsers
/**
* @return \yii\db\ActiveQuery
*/
public function getUsers()
{
return $this->hasMany(User::className(), ['id' => 'user_id'])->viaTable('auth_assignment', ['item_name' => 'name']);
}