/** * Finds the BReviews model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return BReviews the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = BReviews::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionMasters() { $getName = $_GET['name']; if (!$getName) { $query = BMasters::find(); $countQuery = clone $query; $model = BMasters::find()->orderBy('sort ASC')->all(); $BMainpageMasters = BMainpageMasters::find()->where(['site' => 1])->one(); return $this->render('masters', ['model' => $model, 'description' => $BMainpageMasters->text]); } else { $model = BMasters::find()->where(['translate' => $getName])->one(); $allmodel = BMasters::find()->count(); if ($model->sort == $allmodel) { $nextmaster = 1; $prevmaster = $model->sort - 1; } else { if ($model->sort == 1) { $nextmaster = $model->sort + 1; $prevmaster = $allmodel; } else { $nextmaster = $model->sort + 1; $prevmaster = $model->sort - 1; } } $nextmastertranslate = BMasters::find()->where(['sort' => $nextmaster])->one(); $prevmastertranslate = BMasters::find()->where(['sort' => $prevmaster])->one(); $reviews = BReviews::find()->where('section = "masters" AND translate = "' . $getName . '" AND moderate = 1')->orderBy('id DESC')->all(); if (!$model) { return $this->render('error', ['name' => 'Not Found (#404)', 'message' => 'Страница не найдена']); } if (Yii::$app->getSession()->getFlash('captcha')) { $captcha = false; } else { $captcha = true; } if (Yii::$app->getSession()->getFlash('save')) { $save = true; } else { $save = false; } return $this->render('masters_detail', ['model' => $model, 'nextmastertranslate' => $nextmastertranslate, 'prevmastertranslate' => $prevmastertranslate, 'reviews' => $reviews, 'captcha' => $captcha, 'save' => $save]); } }