diff --git a/backend/controllers/CommentController.php b/backend/controllers/CommentController.php index 19376a3..1ab8bb2 100644 --- a/backend/controllers/CommentController.php +++ b/backend/controllers/CommentController.php @@ -13,8 +13,10 @@ use artbox\core\admin\actions\View; use artbox\core\admin\widgets\Form; use common\models\Comment; + use common\models\Service; use yii\filters\AccessControl; use yii\filters\VerbFilter; + use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -103,6 +105,7 @@ public function findModel($id) { + $model = Comment::find() ->where([ 'id' => $id ]) ->one(); @@ -122,6 +125,7 @@ ] ) ->one(); + return $category->delete(); } @@ -129,7 +133,8 @@ public function actionUpdate($id) { $model = $this->findModel($id); - + $services = Service::find()->all(); + $data = ArrayHelper::map($services, 'id', 'title'); if ($model->load(\Yii::$app->request->post()) && $model->save()) { return $this->redirect('index'); } else { @@ -137,6 +142,7 @@ 'update', [ 'model' => $model, + 'services' => $data ] ); } diff --git a/backend/controllers/QuestionController.php b/backend/controllers/QuestionController.php index a02749a..795b6dd 100644 --- a/backend/controllers/QuestionController.php +++ b/backend/controllers/QuestionController.php @@ -13,8 +13,10 @@ use artbox\core\admin\actions\View; use artbox\core\admin\widgets\Form; use common\models\Question; + use common\models\Service; use yii\filters\AccessControl; use yii\filters\VerbFilter; + use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -129,7 +131,8 @@ public function actionUpdate($id) { $model = $this->findModel($id); - + $services = Service::find()->all(); + $data = ArrayHelper::map($services, 'id', 'title'); $model->scenario = Question::SCENARIO_ANSWER; if ($model->load(\Yii::$app->request->post()) && $model->save()) { return $this->redirect('index'); @@ -138,6 +141,7 @@ 'update', [ 'model' => $model, + 'services' => $data ] ); } diff --git a/backend/views/comment/_form.php b/backend/views/comment/_form.php index a25ab7f..e61235f 100644 --- a/backend/views/comment/_form.php +++ b/backend/views/comment/_form.php @@ -1,5 +1,6 @@ registerJs($js, View::POS_READY); + ?>
Ваш отзыв появиться после проверки модератором
") + data.validated = false; + }', + + ], + 'questions' => [ + 'class' => 'artbox\core\forms\Module', + 'activeRecord' => "common\models\Question", + 'attributes' => [ + 'name', + 'email', + 'question', + 'service_id' + ], + 'rules' => [ + [ + [ + 'name', + 'email', + ], + 'required', + ] + ], + 'labels' => [ + 'name' => 'ФИО', + 'email' => 'Email', + 'question' => 'Ваш вопрос', + 'service_id' => false + ], + + 'inputOptions' => [ + 'name' => [ + 'template' => 'Спасибо за Вваш вопрос. Мы обязательно на него ответим
") + data.validated = false; + }', + + ], ], 'components' => [ 'assetManager' => [ diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index fe29514..6d8fb9b 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -19,7 +19,6 @@ use common\models\Service; use common\models\Settings; use frontend\assets\AppAsset; - use artbox\core\components\imagemanager\models\ImageManager; use frontend\assets\SliderAsset; use frontend\widgets\ArtboxModalWidget; use frontend\widgets\LanguageWidget; @@ -166,7 +165,7 @@ } $items[] = [ 'label' => \Yii::t('app', 'Цены'), - 'url' => '#', + 'url' => Url::to(['site/prices']), 'options' => [ 'class' => 'active' ] diff --git a/frontend/views/service/view.php b/frontend/views/service/view.php index 1b0f64a..1581b2a 100644 --- a/frontend/views/service/view.php +++ b/frontend/views/service/view.php @@ -2,15 +2,29 @@ /** * @var \common\models\Service $model; * @var \common\models\Service[] $others; + * @var \artbox\core\forms\Module $moduleComment; + * @var \artbox\core\forms\Module $moduleQuestion; */ use artbox\core\helpers\Url; - $this->params[ 'breadcrumbs' ][] = $model->title + $moduleComment = \Yii::$app->getModule('comments'); + $this->params[ 'breadcrumbs' ][] = $model->title; + + $moduleComment->inputOptions += ['service_id' => [ + 'type' => 'hiddenInput', + 'options' => ['value' => $model->id], + ]]; + + $moduleQuestion = \Yii::$app->getModule('questions'); + $moduleQuestion->inputOptions += ['service_id' => [ + 'type' => 'hiddenInput', + 'options' => ['value' => $model->id], + ]]; ?>