public function run() { $model = new Comments(); if (!is_string($this->model)) { $model->post_id = $this->model->getPrimaryKey(); $model->module = get_class($this->model); $order = ''; } else { $model->post_id = 0; $model->module = $this->model; $order = 'DESC'; } // Получаем комментарии этого модуля и пост айди $models = Comments::getComments($model->module, $model->post_id, $order); // Получаем кол-во страниц комментариев для редиректа $page = $models['pages']->totalCount / $models['pages']->pageSize + 1; if ($model->load(Yii::$app->request->post())) { if ($model->save()) { Url::remember(Url::current()); Yii::$app->getSession()->setFlash('success', '<i class="fa fa-check fa-1x"></i> Good! '); if (!is_string($this->model)) { return Yii::$app->getResponse()->redirect('/post/' . $this->model->slug . '/' . $model->post_id . '?page=' . round($page) . '#' . $model->id); } else { return Yii::$app->getResponse()->refresh(); } } } return $this->render('widgetComment', ['model' => $model, 'models' => $models['models'], 'pages' => $models['pages'], 'options' => $this->options]); }