Sorry I am new to yii2 I am trying so hard to get used to it I really just want to display my user’s first name rather than his ID and cannot understand what I must do to retrieve due to the fact that the ID is in one table and the name is in another. This is my db and code:
I have got 3 tables:
tbl_user_notification:
id(PK), comment
tbl_user_notification_users:
id(PK), n_id (FK), user_id (FK)
tbl_user:
id(PK), first_name, last_name
In the index page of notification, I want to display the comment (from tbl_user_notification) and the first and last names of the users the notification was sent to (from tbl_user).
I am only managing to display the ID on the index page however. How can I show the name pls?
Notification model:
public function getNotifUsers()
{
return $this->hasOne(NotificationsUsers::className(), ['n_id' => 'id']);
}
My notification index page:
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//'id',
[
'label' => 'First Name',
'value' => 'notifUsers.user_id',
],
'comments',