Commit 75f71ad4034222c29f7be14fe57dc32ef1ccba0b
Merge branch 'master' of gitlab.artweb.com.ua:steska/clinica
Showing
1 changed file
with
17 additions
and
4 deletions
Show diff stats
frontend/controllers/SiteController.php
@@ -80,6 +80,7 @@ | @@ -80,6 +80,7 @@ | ||
80 | )->orderBy([ new Expression('sort ASC NULLS LAST') ]) | 80 | )->orderBy([ new Expression('sort ASC NULLS LAST') ]) |
81 | ->all(); | 81 | ->all(); |
82 | $comments = Comment::find()->where(['status' => true, 'on_main' => true])->limit(6)->all(); | 82 | $comments = Comment::find()->where(['status' => true, 'on_main' => true])->limit(6)->all(); |
83 | + | ||
83 | $package = Package::find()->with(['language.alias'])->where(['status' => true])->orderBy('sort')->limit(3)->all(); | 84 | $package = Package::find()->with(['language.alias'])->where(['status' => true])->orderBy('sort')->limit(3)->all(); |
84 | $settings = Settings::getInstance(); | 85 | $settings = Settings::getInstance(); |
85 | return $this->render('index', [ | 86 | return $this->render('index', [ |
@@ -272,11 +273,15 @@ | @@ -272,11 +273,15 @@ | ||
272 | } | 273 | } |
273 | 274 | ||
274 | public function actionComments($service_id = null){ | 275 | public function actionComments($service_id = null){ |
275 | - | 276 | + |
276 | if (\Yii::$app->request->isAjax){ | 277 | if (\Yii::$app->request->isAjax){ |
277 | Yii::$app->response->format = Response::FORMAT_JSON; | 278 | Yii::$app->response->format = Response::FORMAT_JSON; |
278 | $model = new Comment(); | 279 | $model = new Comment(); |
279 | - if ($model->load(\Yii::$app->request->post()) and $model->save()){ | 280 | + #if ($model->load(\Yii::$app->request->post()) and $model->save()){ |
281 | + if ($model->load(\Yii::$app->request->post())){ | ||
282 | + if(!$model->entity_id)$model->entity_id=0; | ||
283 | + $model->entity=Service::className(); | ||
284 | + $model->save(); | ||
280 | return [ | 285 | return [ |
281 | 'status' => true, | 286 | 'status' => true, |
282 | 'message' => 'Спасибо за Ваш отзыв. После проверки модератором он появиться на сайте' | 287 | 'message' => 'Спасибо за Ваш отзыв. После проверки модератором он появиться на сайте' |
@@ -288,14 +293,22 @@ | @@ -288,14 +293,22 @@ | ||
288 | ]; | 293 | ]; |
289 | } | 294 | } |
290 | } | 295 | } |
296 | + | ||
297 | + | ||
298 | + # подкоректировал логику для сохранрения в БД/выдачи вопросов с категории "Общие вопросы" | ||
299 | + # закрепил за ними entity_id=0 | ||
300 | + if($service_id==null)$service_id=0; | ||
291 | $dataProvider = new ActiveDataProvider([ | 301 | $dataProvider = new ActiveDataProvider([ |
292 | - 'query' => Comment::find()->where(['status' => true])->andWhere(['entity' => Service::className()])->andFilterWhere(['entity_id' => $service_id]), | 302 | + 'query' => Comment::find() |
303 | + ->where(['status' => true]) | ||
304 | + ->andWhere(['entity' => Service::className()]) | ||
305 | + ->andFilterWhere(['entity_id' => $service_id]),//'SELECT * FROM \"comment\" WHERE (\"status\"=TRUE) AND (\"entity\"=\'common\\models\\Service\')' | ||
293 | 'pagination' => [ | 306 | 'pagination' => [ |
294 | 'pageSize' => 10, | 307 | 'pageSize' => 10, |
295 | ], | 308 | ], |
296 | ]); | 309 | ]); |
297 | $services = Service::find()->where(['status' => true])->andWhere(['parent_id' => null])->all(); | 310 | $services = Service::find()->where(['status' => true])->andWhere(['parent_id' => null])->all(); |
298 | - | 311 | + |
299 | return $this->render('comments', [ | 312 | return $this->render('comments', [ |
300 | 'dataProvider' => $dataProvider, | 313 | 'dataProvider' => $dataProvider, |
301 | 'services' => $services, | 314 | 'services' => $services, |