How to display username instead of id?

Hello everybody! First, describe the situation, there are three table documents, doc_sign and user. In the documents table respectively loaded documents when viewing a document, the user clicks the button "Read", and a document id and user id are recorded in the table doc_sign. The problem is that in a view related to table documents I have to get the user name, and it turns out to bring only id. The relationship of the models I have established between documents and doc_sign and between doc_sign and user, but once again, the problem is that the user name I need to bring to the table the documents. Custom id output the following:
<?php foreach($model->docsign as $key => $value): ?>
 <?= $value->user_id ?>
<?php endforeach; ?>
March 19th 20 at 09:27
2 answers
March 19th 20 at 09:29
Solution
$value->user->name
March 19th 20 at 09:31
Solution
You can build a chain through which to obtain the user name.
Something like:
// $model it Documents
$model->docsign->user->name;

In Your case, you can try this:
<?php foreach($model->docsign as $key => $value): ?>
 <?= $value->user->name ?>
<?php endforeach; ?>

Or create another link or method to get the user name.

Find more questions by tags Yii