I have a user_detail table
CREATE TABLE `user_detail` (
`id` int(11) unsigned NOT NULL,
`userID` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
);
I want to retrieve the value of user_detail
.name
in main.php to display the loggedin user's name.
in UserDelail class I added a getter:
public function getFullName()
{
return $this->hasOne(UserDetail::className(), ['userID' => Yii::$app->user->identity->id]);
}
In main.php I have <?= UserDetail::getFullName()->name ?>
and I am getting: Calling unknown method: yii\web\View::hasOne()
What is wrong here? and how can i correct that?
Thank you