public static function getVideosComments($articleId) { $query = VideosComments::find(); $query->with('commentOwner'); $query->andFilterWhere(['video_id' => $articleId]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 6], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); return $dataProvider; }
public function actionView($title) { /* $videoId = explode('-', $title); return $this->render('view', [ 'model' => $this->findModel($videoId[1]), ]);*/ $videoId = explode('-', $title); $videoModel = new VideosComments(); $model = new VideosComments(); $model->user_id = Yii::$app->user->id; $video = $this->findModel($videoId[1]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->render('view', ['model' => $video, 'videosComments' => $videoModel, 'videosCommentsList' => VideosComments::getVideosComments($videoId[1]), 'popularVideos' => Videos::getPopularVideos()]); } if ($videoId[1]) { $videoModel->video_id = $videoId[1]; return $this->render('view', ['model' => $video, 'videosComments' => $videoModel, 'videosCommentsList' => VideosComments::getVideosComments($videoId[1]), 'popularVideos' => Videos::getPopularVideos()]); } }