Commit a4320bd1d07dc2bba19615ade8065c0830eef0a2
1 parent
937888fd
- bug fix
Showing
6 changed files
with
53 additions
and
2 deletions
Show diff stats
backend/controllers/PackageController.php
... | ... | @@ -164,6 +164,13 @@ |
164 | 164 | 'name' => 'sort', |
165 | 165 | 'type' => Form::NUMBER, |
166 | 166 | ], |
167 | + [ | |
168 | + 'name' => 'service_id', | |
169 | + 'type' => Form::RELATION, | |
170 | + 'relationAttribute' => 'title', | |
171 | + 'relationName' => 'service', | |
172 | + 'multiple' => false, | |
173 | + ] | |
167 | 174 | ], |
168 | 175 | ]; |
169 | 176 | } | ... | ... |
common/models/Package.php
... | ... | @@ -79,7 +79,7 @@ class Package extends ActiveRecord |
79 | 79 | { |
80 | 80 | return [ |
81 | 81 | [['sort', 'created_at', 'updated_at'], 'default', 'value' => null], |
82 | - [['sort', 'created_at', 'updated_at', 'image_id'], 'integer'], | |
82 | + [['sort', 'created_at', 'updated_at', 'image_id', 'service_id'], 'integer'], | |
83 | 83 | [['status'], 'boolean'], |
84 | 84 | ]; |
85 | 85 | } |
... | ... | @@ -130,4 +130,8 @@ class Package extends ActiveRecord |
130 | 130 | return $this->hasOne(Image::className(), ['id' => 'image_id']); |
131 | 131 | } |
132 | 132 | |
133 | + public function getService(){ | |
134 | + return $this->hasOne(Service::className(), ['id' => 'service_id']); | |
135 | + } | |
136 | + | |
133 | 137 | } | ... | ... |
common/models/Service.php
... | ... | @@ -162,4 +162,8 @@ class Service extends ActiveRecord |
162 | 162 | public function getQuestions(){ |
163 | 163 | return $this->hasMany(Question::className(), ['service_id' => 'id']); |
164 | 164 | } |
165 | + | |
166 | + public function getPackages(){ | |
167 | + return $this->hasMany(Package::className(), ['service_id' => 'id']); | |
168 | + } | |
165 | 169 | } | ... | ... |
frontend/controllers/ServiceController.php
... | ... | @@ -20,6 +20,9 @@ |
20 | 20 | $model = $this->findModel($id); |
21 | 21 | if ($model->parent_id == null){ |
22 | 22 | $others = Service::find()->where(['parent_id' => $model->id])->with('services.language.alias')->all(); |
23 | + if (empty($others)){ | |
24 | + $others = Service::find()->where(['parent_id' => null, 'status' => true])->all(); | |
25 | + } | |
23 | 26 | }elseif ($model->level == 1){ |
24 | 27 | $others = Service::find()->where(['parent_id' => $model->parent_id])->with('services.language.alias')->all(); |
25 | 28 | }else{ |
... | ... | @@ -42,6 +45,8 @@ |
42 | 45 | $query->where(['status' => true]); |
43 | 46 | }, 'questions' => function (ActiveQuery $query){ |
44 | 47 | $query->where(['status' => true])->with('doctor'); |
48 | + },'packages' => function (ActiveQuery $query){ | |
49 | + $query->with(['image', 'language'])->where(['status' => true]); | |
45 | 50 | }])->one(); |
46 | 51 | if (empty($model)){ |
47 | 52 | throw new NotFoundHttpException('Model not found'); | ... | ... |
frontend/views/service/view.php
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | * @var \yii\web\View $this |
8 | 8 | * @var \artbox\core\components\SeoComponent $seo; |
9 | 9 | */ |
10 | + use artbox\core\helpers\ImageHelper; | |
10 | 11 | use artbox\core\helpers\Url; |
11 | 12 | use common\models\Service; |
12 | 13 | |
... | ... | @@ -77,6 +78,36 @@ |
77 | 78 | <?php }?> |
78 | 79 | </ul> |
79 | 80 | </div> |
81 | + <div class="style"> | |
82 | + <?php if (!empty($model->packages)){ | |
83 | + foreach ($model->packages as $package){?> | |
84 | + <div class="packages-page-col"> | |
85 | + <a class="packages-page-link" href="<?=Url::to(['alias' => $package->language->alias])?>"> | |
86 | + <div class="img-packages-page"> | |
87 | + <!--555x344--> | |
88 | + <?=ImageHelper::set(($package->image) ? $package->image->getPath() : null) | |
89 | + ->resize(262, 135) | |
90 | + ->quality(84) | |
91 | + ->renderImage()?> | |
92 | + </div> | |
93 | + <div class="table-packages-wr"> | |
94 | + <table cellspacing="0" cellpadding="0" border="0"> | |
95 | + <tr> | |
96 | + <td><span class="title-packages"><?=$package->title?></span></td> | |
97 | + </tr> | |
98 | + <tr> | |
99 | + <td> | |
100 | + <span class="btn_ packages-btn"><?=\Yii::t('app','More info');?></span> | |
101 | + </td> | |
102 | + </tr> | |
103 | + </table> | |
104 | + </div> | |
105 | + </a> | |
106 | + </div> | |
107 | + <?php } | |
108 | + | |
109 | + }?> | |
110 | + </div> | |
80 | 111 | </div> |
81 | 112 | <div class="col-xs-12 col-sm-8 col-md-8 col-lg-9"> |
82 | 113 | <div class="row"> | ... | ... |
frontend/views/site/comments.php
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | use yii\widgets\ActiveForm; |
15 | 15 | use yii\widgets\ListView; |
16 | 16 | |
17 | - $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Quest/Answer'); | |
17 | + $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Отзывы'); | |
18 | 18 | |
19 | 19 | $model = new Comment(['entity_id' => $service_id, 'entity' => Service::className()]); |
20 | 20 | ... | ... |