Advertisement
strogj

BlogController

Apr 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. public function actionView($id){
  2.   $comment = new Comments();
  3.   $article = Blog::find()->where(['id' => $id])->all();
  4.   $query = Comments::find()->where(['page' => $id]);
  5.  
  6.  // $query = Comments::find()->where('body=page',['page'=>$id]);
  7.    
  8.   $dataProvider = new ActiveDataProvider([
  9.     'query' => $query,
  10.     'pagination' => [
  11.             'pageSize' => 10,
  12.         ]
  13.     ]);
  14.  
  15.    if ($comment->load(Yii::$app->request->post()) && $comment->post()) {
  16.         return $this->refresh();
  17.     }
  18.  
  19.     return $this->render('view', [
  20.       'article' => $article,
  21.       'dataProvider' => $dataProvider,
  22.       'comment' => $comment,
  23.     ]);
  24.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement