Example #1
0
 public function actionView($title)
 {
     $articleId = explode('-', $title);
     $articleModel = new ArticleComments();
     $model = new ArticleComments();
     $model->user_id = Yii::$app->user->id;
     $article = $this->findModel($articleId[1]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->render('view', ['model' => $article, 'articleComments' => $articleModel, 'articleCommentsList' => ArticleComments::getArticleComments($articleId[1]), 'popularPosts' => Article::getPopularPosts(), 'author' => Profile::findOne(['user_id' => $article['psychologist_id']])]);
     }
     if ($articleId[1]) {
         $articleModel->article_id = $articleId[1];
         return $this->render('view', ['model' => $article, 'articleComments' => $articleModel, 'articleCommentsList' => ArticleComments::getArticleComments($articleId[1]), 'popularPosts' => Article::getPopularPosts(), 'author' => Profile::findOne(['user_id' => $article['psychologist_id']])]);
     }
 }