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
Post a Comment