php - not receiving all data from database, yii2 -


controller action render index page

public function actionindex()     {         $posts = posts::find()->all();         $user = user::find()->all;         return $this->render('index', [             'posts' => $posts,             'user' => $user         ]);     } 

view:

<? foreach ($posts $post){?>     <div class="well">         <h5><?=$user[$post->user_id-1]->login ?></h5>         <?=$post->text ?>     </div>     <?} ?> 

posts texts displayed users logins not. why? var_dump($users) shows nothing. checked table. there records in users table.

public function actionindex() {     $posts = posts::find()->all();     $user = user::find()->all();     return $this->render('index', [         'posts' => $posts,         'user' => $user     ]); } 

use user::find()->all(); not user::find()->all;


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -