How to display data from related table using Arrayelper::index?

The problem I have is that I was able to bring the data below are grouped by date. Just do not understand how to display data from related data
In the controller
$comment = Comment::find()->addSelect(['DATE(date) as just_date','TIME(date) as time','comment','id_user'])->where(['id_zakaz' => $id])->asArray()->all();
 $comment = ArrayHelper::index($comment, null, 'just_date');

In the view
<?php foreach ($comment as $key=-->$com){
 echo Yii::$app->formatter->asDate($key, 'php:j M Y').'<br>';
 foreach ($com as $value=>$name){
 echo Yii::$app->formatter->asTime(ArrayHelper::getValue($name, 'time'), 'php:H:i').' '.ArrayHelper::getValue($name, 'comment').' '.ArrayHelper::getValue($name, 'id_user').'<br>';
}
 } ?>

That is, I need id_user->idUser->name. Just a thought I had to make another request, it would be logical in the query to make another query
June 14th 19 at 20:41
1 answer
June 14th 19 at 20:43
Solution
load related data by using joinWith and then choose what You need
And if you use with() it does not matter what is used it is not joinWith? - Waylon_Kub commented on June 14th 19 at 20:46
for Your task it's best to use joinWith - bryana.Renn commented on June 14th 19 at 20:49

Find more questions by tags Yii