A
A
Alexander Laikov2017-02-19 01:31:03
Yii
Alexander Laikov, 2017-02-19 01:31:03

What data does $app->user->identity store?

Good afternoon.
There is such a table
8a945d76418746409c0fcbca09da22be.jpg
With the help of $app->user->idendity I can pull out the fields id, name, password, email
How to pull out the rest?
Or each time to make a request to the table, but this is not very rational.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-02-19
@Florens

Everything that is in the user model is there. But I don’t see a problem to check it myself, for clarity, for example, like this:

<pre>
<?php print_r(Yii::$app->user->idendity); ?>
</pre>

D
Dmitry, 2017-02-19
@slo_nik

Goodnight.
For example, the money field.
But it is better to leave the data for authorization, tokens and other service information in the table, and move the detailed information about the user to another table, name it, for example, profile and link it to the first table by user id.
In the profile model

public function getUser()
{
  return $this->hasOne(User::className(), ['id' => 'id_user']);
}

In the User model
public function getProfile()
{
  return $this->hasOne(Profile::className(), ['id_user' => 'id']);
}

Learn more about relationships between models here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question