How to create a relation with yii2-user?

I want to create a link,for example a user post. Using yii2-user. In the config file like this:
'user' => [
 'class' => 'dektrium\user\Module',
 'enableConfirmation' => false,
 'modelMap' => [
 'User' => 'app\models\User',
],
 ],

modelMap just to work with User model. And in the post and the user now has methods with svzya, the user is getPosts(). Now I want to get all posts of a user in a controller method, obtained Yii::$app->user-> and here no method getPosts(). How can I bypass?
June 14th 19 at 20:24
1 answer
June 14th 19 at 20:26
In the config
'user' => [
 'identityClass' => 'app\models\User'
 /* ... */
],


In the User model
class User /* ... */ implements \yii\web\IdentityInterface 
{
/* ... */
}


In the controller:
Yii::$app->user->identity->getPosts();

Find more questions by tags PHP