Commit d578e98de5631783fe24049853000b10602b599d
1 parent
454c28e8
alias
Showing
4 changed files
with
123 additions
and
127 deletions
Show diff stats
common/models/ServiceLang.php
| @@ -133,10 +133,4 @@ | @@ -133,10 +133,4 @@ | ||
| 133 | { | 133 | { |
| 134 | return $this->hasOne(Service::className(), [ 'id' => 'service_id' ]); | 134 | return $this->hasOne(Service::className(), [ 'id' => 'service_id' ]); |
| 135 | } | 135 | } |
| 136 | - | ||
| 137 | - public function getQuestionAlias(){ | ||
| 138 | - return $this->hasOne(Alias::className(), []) | ||
| 139 | - ->where(['route' => Json::encode(['site\questions', 'service_id' => $this->service_id])]) | ||
| 140 | - ->andWhere(['language_id' => $this->language_id]); | ||
| 141 | - } | ||
| 142 | } | 136 | } |
frontend/controllers/SiteController.php
| @@ -15,6 +15,8 @@ | @@ -15,6 +15,8 @@ | ||
| 15 | use yii\db\ActiveQuery; | 15 | use yii\db\ActiveQuery; |
| 16 | use yii\db\Expression; | 16 | use yii\db\Expression; |
| 17 | use yii\filters\VerbFilter; | 17 | use yii\filters\VerbFilter; |
| 18 | + use yii\helpers\ArrayHelper; | ||
| 19 | + use yii\helpers\Json; | ||
| 18 | use yii\swiftmailer\Mailer; | 20 | use yii\swiftmailer\Mailer; |
| 19 | use yii\web\BadRequestHttpException; | 21 | use yii\web\BadRequestHttpException; |
| 20 | use yii\web\Controller; | 22 | use yii\web\Controller; |
| @@ -251,17 +253,17 @@ | @@ -251,17 +253,17 @@ | ||
| 251 | 'pageSize' => 10, | 253 | 'pageSize' => 10, |
| 252 | ], | 254 | ], |
| 253 | ]); | 255 | ]); |
| 254 | - $services = Service::find()->with('language.questionAlias')->where(['status' => true])->andWhere(['parent_id' => null])->all(); | ||
| 255 | - # d::dump($services[3]->id,10,1); | ||
| 256 | - #d::dump($dataTest,10,1); | ||
| 257 | - #die; | ||
| 258 | - | ||
| 259 | - | 256 | + $services = Service::find()->where(['status' => true])->andWhere(['parent_id' => null])->all(); |
| 257 | + $route = []; | ||
| 258 | + foreach ($services as $service){ | ||
| 259 | + $route[] = Json::encode(['site/questions', 'service_id' => $service->id]); | ||
| 260 | + } | ||
| 261 | + $alias = Alias::find()->where(['route' => $route])->andWhere(['language_id' => Language::getCurrent()->id])->indexBy('route')->asArray()->all(); | ||
| 260 | return $this->render('questions', [ | 262 | return $this->render('questions', [ |
| 261 | 'dataProvider' => $dataProvider, | 263 | 'dataProvider' => $dataProvider, |
| 262 | 'services' => $services, | 264 | 'services' => $services, |
| 263 | 'service_id' => $service_id, | 265 | 'service_id' => $service_id, |
| 264 | - | 266 | + 'alias' => $alias |
| 265 | ]); | 267 | ]); |
| 266 | } | 268 | } |
| 267 | 269 |
frontend/views/site/questions.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @var \yii\data\ActiveDataProvider $dataProvider | 3 | * @var \yii\data\ActiveDataProvider $dataProvider |
| 4 | - * @var \common\models\Service[] $services | ||
| 5 | - * @var \yii\web\View $this | ||
| 6 | - * @var int $service_id | 4 | + * @var \common\models\Service[] $services |
| 5 | + * @var \yii\web\View $this | ||
| 6 | + * @var int $service_id | ||
| 7 | + * @var array $alias; | ||
| 7 | */ | 8 | */ |
| 8 | 9 | ||
| 9 | use artbox\core\helpers\Url; | 10 | use artbox\core\helpers\Url; |
| 10 | use common\models\Question; | 11 | use common\models\Question; |
| 11 | use yii\helpers\ArrayHelper; | 12 | use yii\helpers\ArrayHelper; |
| 12 | use yii\helpers\Html; | 13 | use yii\helpers\Html; |
| 14 | + use yii\helpers\Json; | ||
| 13 | use yii\widgets\ActiveForm; | 15 | use yii\widgets\ActiveForm; |
| 14 | use yii\widgets\ListView; | 16 | use yii\widgets\ListView; |
| 15 | use yii\helpers\VarDumper as d; | 17 | use yii\helpers\VarDumper as d; |
| 16 | use artbox\core\models\Alias; | 18 | use artbox\core\models\Alias; |
| 17 | - | ||
| 18 | - | ||
| 19 | - $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Quest/Answer'); | ||
| 20 | 19 | ||
| 21 | - $model = new Question(['service_id' => $service_id]); | 20 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Quest/Answer'); |
| 21 | + | ||
| 22 | + $model = new Question([ 'service_id' => $service_id ]); | ||
| 22 | $model->scenario = Question::SCENARIO_QUESTION; | 23 | $model->scenario = Question::SCENARIO_QUESTION; |
| 23 | 24 | ||
| 24 | - $data = ['' =>\Yii::t('app','General issues')] + ArrayHelper::map($services, 'id', 'title'); | ||
| 25 | - ?> | 25 | + $data = [ '' => \Yii::t('app', 'General issues') ] + ArrayHelper::map($services, 'id', 'title'); |
| 26 | +?> | ||
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | <section class="section-service-page section-answer-page"> | 29 | <section class="section-service-page section-answer-page"> |
| 29 | - <div class="container"> | ||
| 30 | - <div class="row"> | ||
| 31 | - <div class="col-xs-12 col-sm-12"> | ||
| 32 | - <h1 class="title-pages"><?=\Yii::t('app','Quest/Answer')?></h1> | ||
| 33 | - </div> | 30 | + <div class="container"> |
| 31 | + <div class="row"> | ||
| 32 | + <div class="col-xs-12 col-sm-12"> | ||
| 33 | + <h1 class="title-pages"><?= \Yii::t('app', 'Quest/Answer') ?></h1> | ||
| 34 | + </div> | ||
| 35 | + </div> | ||
| 36 | + <div class="row"> | ||
| 37 | + <div class="col-xs-12 col-sm-12"> | ||
| 38 | + <div class="style add-answer-forms"> | ||
| 39 | + <span class="btn_"><?= \Yii::t('app', 'Asc question'); ?></span> | ||
| 34 | </div> | 40 | </div> |
| 35 | - <div class="row"> | ||
| 36 | - <div class="col-xs-12 col-sm-12"> | ||
| 37 | - <div class="style add-answer-forms"> | ||
| 38 | - <span class="btn_"><?=\Yii::t('app','Asc question');?></span> | ||
| 39 | - </div> | ||
| 40 | - <div class="style hidden-answer-comment-form hidden"> | ||
| 41 | - <div class="hidden-answer-comment-form-title"><?=\Yii::t('app','Asc question');?></div> | ||
| 42 | - <?php $form = ActiveForm::begin(['id' => 'total_question_form'])?> | ||
| 43 | - <div class="col-xs-12 col-sm-6"> | ||
| 44 | - <div class="input-wr"> | ||
| 45 | - <?=$form->field($model, 'service_id')->dropDownList($data) | ||
| 46 | - ->label(\Yii::t('app','Choosing department'))?> | ||
| 47 | - </div> | ||
| 48 | - | ||
| 49 | - <div class="input-wr required"> | ||
| 50 | - <?=$form->field($model, 'name') | ||
| 51 | - ->label(\Yii::t('app','FIO'))?> | ||
| 52 | - </div> | ||
| 53 | - <div class="input-wr required"> | ||
| 54 | - <?=$form->field($model, 'email') | ||
| 55 | - ->label(\Yii::t('app','Email'))?> | ||
| 56 | - </div> | ||
| 57 | - </div> | ||
| 58 | - <div class="col-xs-12 col-sm-6"> | ||
| 59 | - <div class="input-wr"> | ||
| 60 | - <?=$form->field($model, 'question')->textarea(['cols' => 30, 'rows' => 10]) | ||
| 61 | - ->label(\Yii::t('app','Yours question'))?> | ||
| 62 | -<!-- <label class="control-label" for="feedback-name">Ваш вопрос</label>--> | ||
| 63 | -<!-- <textarea name="" id="" cols="30" rows="10"></textarea>--> | ||
| 64 | - </div> | ||
| 65 | - </div> | ||
| 66 | - <div class="col-xs-12 col-sm-12"> | ||
| 67 | - <div class="button-wr submit-close-wr-c-a"> | ||
| 68 | - <?=Html::submitButton(\Yii::t('app','Send question'))?> | ||
| 69 | -<!-- <button type="submit">Отправить вопрос</button>--> | ||
| 70 | - <div class="submit-close-c-a submit-close-c-a-page"> | ||
| 71 | - <span><?=\Yii::t('app','Minimize a window');?></span></div> | ||
| 72 | - </div> | ||
| 73 | - </div> | ||
| 74 | - <?php $form::end();?> | ||
| 75 | - </div> | 41 | + <div class="style hidden-answer-comment-form hidden"> |
| 42 | + <div class="hidden-answer-comment-form-title"><?= \Yii::t('app', 'Asc question'); ?></div> | ||
| 43 | + <?php $form = ActiveForm::begin([ 'id' => 'total_question_form' ]) ?> | ||
| 44 | + <div class="col-xs-12 col-sm-6"> | ||
| 45 | + <div class="input-wr"> | ||
| 46 | + <?= $form->field($model, 'service_id') | ||
| 47 | + ->dropDownList($data) | ||
| 48 | + ->label(\Yii::t('app', 'Choosing department')) ?> | ||
| 76 | </div> | 49 | </div> |
| 77 | - <div class="col-xs-12 col-sm-12"> | ||
| 78 | - <ul class="answers-category-list"> | ||
| 79 | - <li <?=($service_id == null ? 'class="active"' : '')?>> | ||
| 80 | - <a href="<?=Url::current(['service_id' => null])?>"> | ||
| 81 | - <span><?=\Yii::t('app','General issues');?></span></a></li> | ||
| 82 | - <?php foreach ($services as $service){?> | ||
| 83 | - <li <?=($service_id == $service->id ? 'class="active"' : '')?>> | ||
| 84 | - <?php | ||
| 85 | - $test=Alias::find() | ||
| 86 | - #->where(['route' => \yii\helpers\Json::encode(['site\questions', 'service_id' => $service->id])]) | ||
| 87 | - # ->andWhere(['language_id' => $service->language->language_id])->all(); | ||
| 88 | - #->where(['language_id' => $service->language->language_id]) | ||
| 89 | - ->where(['LIKE','route','"site/questions","service_id":'.$service->id ]) | ||
| 90 | - #->where(['LIKE','route','service_id:'.$service->id ]) | ||
| 91 | - ->andWhere(['language_id' => $service->language->language_id]) | ||
| 92 | - ->all(); | ||
| 93 | - | ||
| 94 | - d::dump($service,10,1); | ||
| 95 | - # d::dump($test,10,1); | ||
| 96 | - die; | ||
| 97 | - | ||
| 98 | - ?> | ||
| 99 | - <a href="<?=($service->language->questionAlias !== null) ?Url::to(['alias' => $service->language->questionAlias]): Url::current(['service_id' => $service->id])?>"><span><?=$service->title?></span></a></li> | ||
| 100 | - <?php } ?> | ||
| 101 | - | ||
| 102 | - | ||
| 103 | - | ||
| 104 | - | ||
| 105 | - | ||
| 106 | - | ||
| 107 | - | ||
| 108 | - </ul> | 50 | + |
| 51 | + <div class="input-wr required"> | ||
| 52 | + <?= $form->field($model, 'name') | ||
| 53 | + ->label(\Yii::t('app', 'FIO')) ?> | ||
| 109 | </div> | 54 | </div> |
| 110 | - <div class="col-xs-12 col-sm-12"> | ||
| 111 | - <div class="service-comments-wr style"> | ||
| 112 | - <?php echo ListView::widget( | ||
| 113 | - [ | ||
| 114 | - 'itemOptions' => [ | ||
| 115 | - ], | ||
| 116 | - 'layout' => '{items}', | ||
| 117 | - 'dataProvider' => $dataProvider, | ||
| 118 | - 'itemView' => '_question' | ||
| 119 | - ] | ||
| 120 | - );?> | ||
| 121 | - | ||
| 122 | - | ||
| 123 | - <div class="style navi-c-a"> | ||
| 124 | - <?php echo \frontend\widgets\FrontendPager::widget( | ||
| 125 | - [ | ||
| 126 | - 'pagination' => $dataProvider->pagination, | ||
| 127 | - 'prevPageLabel' => 'previous', | ||
| 128 | - 'nextPageLabel' => 'next', | ||
| 129 | - 'maxButtonCount' => 3, | ||
| 130 | - 'lastPageLabel' => 'last_number', | ||
| 131 | - ] | ||
| 132 | - );?> | ||
| 133 | - </div> | ||
| 134 | - | ||
| 135 | - | ||
| 136 | - </div> | 55 | + <div class="input-wr required"> |
| 56 | + <?= $form->field($model, 'email') | ||
| 57 | + ->label(\Yii::t('app', 'Email')) ?> | ||
| 58 | + </div> | ||
| 59 | + </div> | ||
| 60 | + <div class="col-xs-12 col-sm-6"> | ||
| 61 | + <div class="input-wr"> | ||
| 62 | + <?= $form->field($model, 'question') | ||
| 63 | + ->textarea( | ||
| 64 | + [ | ||
| 65 | + 'cols' => 30, | ||
| 66 | + 'rows' => 10, | ||
| 67 | + ] | ||
| 68 | + ) | ||
| 69 | + ->label(\Yii::t('app', 'Yours question')) ?> | ||
| 70 | + <!-- <label class="control-label" for="feedback-name">Ваш вопрос</label>--> | ||
| 71 | + <!-- <textarea name="" id="" cols="30" rows="10"></textarea>--> | ||
| 137 | </div> | 72 | </div> |
| 73 | + </div> | ||
| 74 | + <div class="col-xs-12 col-sm-12"> | ||
| 75 | + <div class="button-wr submit-close-wr-c-a"> | ||
| 76 | + <?= Html::submitButton(\Yii::t('app', 'Send question')) ?> | ||
| 77 | + <!-- <button type="submit">Отправить вопрос</button>--> | ||
| 78 | + <div class="submit-close-c-a submit-close-c-a-page"> | ||
| 79 | + <span><?= \Yii::t('app', 'Minimize a window'); ?></span></div> | ||
| 80 | + </div> | ||
| 81 | + </div> | ||
| 82 | + <?php $form::end(); ?> | ||
| 83 | + </div> | ||
| 84 | + </div> | ||
| 85 | + <div class="col-xs-12 col-sm-12"> | ||
| 86 | + <ul class="answers-category-list"> | ||
| 87 | + <li <?= ( $service_id == null ? 'class="active"' : '' ) ?>> | ||
| 88 | + <a href="<?= Url::current([ 'service_id' => null ]) ?>"> | ||
| 89 | + <span><?= \Yii::t('app', 'General issues'); ?></span></a></li> | ||
| 90 | + <?php foreach ($services as $service) { | ||
| 91 | + $route = Json::encode(['site/questions', 'service_id' => $service->id]); | ||
| 92 | + ?> | ||
| 93 | + <li <?= ( $service_id == $service->id ? 'class="active"' : '' ) ?>> | ||
| 94 | + <a href="<?= ( array_key_exists($route, $alias) ) ? Url::to( | ||
| 95 | + [ 'alias' => $alias[$route] ] | ||
| 96 | + ) : Url::current([ 'service_id' => $service->id ]) ?>"><span><?= $service->title ?></span></a></li> | ||
| 97 | + <?php } ?> | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + </ul> | ||
| 101 | + </div> | ||
| 102 | + <div class="col-xs-12 col-sm-12"> | ||
| 103 | + <div class="service-comments-wr style"> | ||
| 104 | + <?php echo ListView::widget( | ||
| 105 | + [ | ||
| 106 | + 'itemOptions' => [], | ||
| 107 | + 'layout' => '{items}', | ||
| 108 | + 'dataProvider' => $dataProvider, | ||
| 109 | + 'itemView' => '_question', | ||
| 110 | + ] | ||
| 111 | + ); ?> | ||
| 112 | + | ||
| 113 | + | ||
| 114 | + <div class="style navi-c-a"> | ||
| 115 | + <?php echo \frontend\widgets\FrontendPager::widget( | ||
| 116 | + [ | ||
| 117 | + 'pagination' => $dataProvider->pagination, | ||
| 118 | + 'prevPageLabel' => 'previous', | ||
| 119 | + 'nextPageLabel' => 'next', | ||
| 120 | + 'maxButtonCount' => 3, | ||
| 121 | + 'lastPageLabel' => 'last_number', | ||
| 122 | + ] | ||
| 123 | + ); ?> | ||
| 124 | + </div> | ||
| 125 | + | ||
| 126 | + | ||
| 138 | </div> | 127 | </div> |
| 128 | + </div> | ||
| 139 | </div> | 129 | </div> |
| 130 | + </div> | ||
| 140 | </section> | 131 | </section> |