public function run() { switch ($this->model instanceof RepliesModel) { case true: switch (empty($this->parentId)) { /** * This issue model was initialed through a model * We need to set the parentId and parentType from the constraints values */ case true: //$this->parentId = $this->model->constraints['parent_id']; //$this->parentType = $this->model->constrain['parent_type']; break; } $searchModel = new RepliesSearch(); $this->model->queryOptions['with'][] = 'replyTo'; $searchModel->addWith($this->model->queryOptions['with']); $get = \Yii::$app->request->getQueryParams(); $params = array_merge($get, $this->model->constraints); unset($params['type']); unset($params['id']); switch (\Yii::$app->user->identity->isAdmin()) { case false: $params['hidden'] = 0; break; } $dataProvider = $searchModel->search($params); $dataProvider->setSort(['defaultOrder' => ['id' => SORT_DESC]]); $this->options['id'] .= $this->parentId; $replies = $this->getView()->render('@nitm/widgets/views/chat/index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'widget' => $this]); //RepliesAsset::register($this->getView()); break; default: //$replies = Html::tag('h3', "No comments", ['class' => 'text-error']); $replies = 'No Replies'; break; } $this->options['id'] .= $this->parentId; return $replies; }