本文整理汇总了PHP中app\models\User::findIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findIdentity方法的具体用法?PHP User::findIdentity怎么用?PHP User::findIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::findIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex($mid = '', $f = 0)
{
$user = User::findIdentity(Yii::$app->user->id);
$regFrm = new RegisterForm();
$rstFrm = new RestorePswForm();
$spOffs = new SpecialOffer();
$spOffs = $spOffs->getAllSpecialOffers();
if ($f) {
$logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN_CAPTCHA]);
} else {
$logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN]);
}
$city = City::find()->all();
$address = new Address();
$distr = $address->getDistrict();
$category = Category::find()->all();
$brand = Brand::find()->all();
$msg = '';
switch ($mid) {
case 1:
$msg = Common::M_EMAIL_SEND;
break;
case 2:
$msg = Common::M_PSW_EMAIL_SEND;
break;
case 3:
$msg = Common::M_PSW_RESTORE_SUCCESS;
break;
}
return $this->render('index', ['msg' => $msg, 'user' => $user, 'spOffs' => $spOffs, 'regFrm' => $regFrm, 'logFrm' => $logFrm, 'rstFrm' => $rstFrm, 'city' => $city, 'distr' => $distr, 'category' => $category, 'brand' => $brand]);
}
示例2: loadEmail
public function loadEmail()
{
$user = User::findIdentity(Yii::$app->user->id);
if ($user) {
$this->email = $user->email;
}
}
示例3: getDateFilterWithPayday
/**
* @return int
*/
public static function getDateFilterWithPayday()
{
$user_id = Yii::$app->user->getId();
$user = User::findIdentity($user_id);
$payday = $user->payday;
if ($payday) {
$currentDay = (int) date("d", time());
$currentMonth = (int) date("m", time());
$currentYear = (int) date("Y", time());
if ($payday <= $currentDay) {
$date = [$currentYear, $currentMonth, $payday];
} else {
// адо искать с прошлого месяца
if ($currentMonth == 1) {
$prevMonth = 12;
$date = [$currentYear, $prevMonth, $payday];
} else {
$date = [$currentYear, $currentMonth - 1, $payday];
}
}
while (checkdate($date[1], $date[2], $date[0]) == false) {
if ($date[2] == 1) {
return null;
}
//WTF
$date[2]--;
}
return $date;
} else {
return null;
}
}
示例4: getUser
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findIdentity($this->id);
}
return $this->_user;
}
示例5: actionIndex
public function actionIndex()
{
$user_id = Yii::$app->user->getId();
$user = User::findIdentity($user_id);
$active_purse = Purse::find()->where(['user_id' => $user_id, 'active' => 1])->one();
$purses = Purse::find()->where(['user_id' => $user_id])->all();
if ($user->payday) {
// если есть дата зп
$datePayDay = DateComponent::getDateFilterWithPayday();
} else {
$datePayDay = [date('Y'), date("m"), 1];
// иначе ставим 1 число текущего месяца
}
$operations = Expense::find()->orderBy('datetime desc')->limit(6)->all();
$types = TypeExpense::find()->where(['user_id' => $user_id])->select(['type_expense.*', TypeExpense::SELECT_SUM])->innerJoinWith(['expenses' => function ($query) use($datePayDay) {
$query->where('date(datetime)>=:date_before', [':date_before' => implode('-', $datePayDay)]);
}])->where(['purse_id' => $active_purse->id])->groupBy('type_expense.id')->all();
$arrTypes = [];
$sum = 0;
foreach ($types as $type) {
$sum += $type->sum;
array_push($arrTypes, ['value' => $type->sum, 'color' => ColorComponent::random_color(), 'label' => $type->name]);
}
// var_dump($types->prepare(Yii::$app->db->queryBuilder)->createCommand()->rawSql);die;
return $this->render('index', ['arrTypes' => $arrTypes, 'date' => $datePayDay[2] . "." . $datePayDay[1] . "." . $datePayDay[0], 'active_purse' => $active_purse, 'purses' => $purses, 'sum' => $sum, 'operations' => $operations]);
}
示例6: loadUser
/**
* Загружаем пользователя
* @return UserModel
*/
public function loadUser()
{
if ($this->_model == null) {
$this->_model = UserModel::findIdentity($this->id);
}
return $this->_model;
}
示例7: beforeValidate
/**
* @inheritdoc
*/
public function beforeValidate()
{
if (parent::beforeValidate()) {
if ($this->scenario == 'user-update') {
// Верификация должностей и пользователей
foreach ($this->position as $key => $positionId) {
if (!isset($this->user[$key])) {
continue;
}
if (!($position = Position::findOne($positionId))) {
continue;
}
if (is_numeric($this->user[$key])) {
$user = User::findIdentity($this->user[$key]);
} else {
$user = User::findByUsername(trim($this->user[$key]));
}
if (!$user) {
continue;
}
$this->_verifyPositions[] = ['positionId' => $position->id, 'userId' => $user->id];
}
if (empty($this->_verifyPositions)) {
$this->addError('position', 'Вы должны указать минимум одну должность');
}
}
return true;
}
return false;
}
示例8: actionView
/**
* Просмотр
*
* @param $id
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
$model = User::findIdentity($id);
if (!$model) {
throw new NotFoundHttpException();
}
return $this->render('view', ['model' => $model]);
}
示例9: __construct
public function __construct($config = [])
{
if (Yii::$app->user->isGuest) {
throw new Exception('Method not allowed to guest users.');
}
$this->_user = User::findIdentity(Yii::$app->user->id);
parent::__construct($config);
}
示例10: actionUser
public function actionUser()
{
if (Yii::$app->user->isGuest) {
$this->goHome();
}
$user = User::findIdentity(Yii::$app->getUser()->getId());
return $this->render('user', ['username' => $user->getUsername()]);
}
示例11: actionIndex
public function actionIndex()
{
$user = User::findIdentity(Yii::$app->user->id);
$regFrm = new RegisterForm();
$logFrm = new LoginForm();
$rstFrm = new RestorePswForm();
return $this->render('about', ['user' => $user, 'regFrm' => $regFrm, 'logFrm' => $logFrm, 'rstFrm' => $rstFrm]);
}
示例12: actionMe
public function actionMe()
{
$user = User::findIdentity(Yii::$app->user->id);
if (!$user) {
return ['success' => 0, 'payload' => 'Some error occurred'];
}
return ['success' => 1, 'payload' => $user];
}
示例13: actionIndex
public function actionIndex()
{
$user = new User();
if (!\Yii::$app->user->isGuest) {
$id = Yii::$app->user->id;
$user = User::findIdentity($id);
}
return $this->render('index', array('user' => $user));
}
示例14: validateOldPassword
public function validateOldPassword($attribute, $params)
{
if (!$this->hasErrors()) {
$user = User::findIdentity(Yii::$app->user->id);
if ($user && !$user->validatePassword($this->old_password)) {
$this->addError($attribute, Common::M_WRONG_PASSWORD);
}
}
}
示例15: actionShow
/**
* Ajax Call
* Zeigt die Details des Benutzer an
*
* @param type $id
*
* @author KAS <kassel@weitkamper.de> 17.06.2015
*/
public function actionShow($id)
{
#Yii::$app->view->params['headline'] = 'Benutzer Verwalten';
// Daten des Users
$model = User::findIdentity($id);
// Ansicht rendern im JSON Format
\Yii::$app->response->format = Response::FORMAT_JSON;
return $this->renderAjax('show', ['model' => $model]);
}