/** * Finds the ReviewCategory model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $slug * @return ReviewCategory the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($slug) { if (($model = ReviewCategory::findOne(['slug' => $slug])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function run() { parent::run(); // TODO: Change the autogenerated stub $categoryRoot = ReviewCategory::findOne(['tree' => $this->root, 'parent_id' => null]); $categoryRootTitle = $categoryRoot->title; $categories = ReviewCategory::find()->where(['tree' => $this->root, 'status' => 10])->andWhere(['<>', 'parent_id', ''])->addOrderBy(['tree' => SORT_ASC])->addOrderBy(['lft' => SORT_ASC])->all(); return $this->render('ReviewCategoryWidget', ['title' => $categoryRootTitle, 'categories' => $categories]); }
public function run() { parent::run(); // TODO: Change the autogenerated stub $categoriesData = ReviewCategory::findOne($this->category_id)->leaves()->all(); $categories = array(); $categories[] = $this->category_id; if ($categoriesData) { foreach ($categoriesData as $category) { $categories[] = $category->id; } } $offset = Review::find()->where(['in', 'category_id', $categories])->andWhere(['>', 'id', $this->node_id])->andFilterWhere(['status' => 10])->orderBy(['id' => SORT_DESC])->count(); $nodes = Review::find()->where(['in', 'category_id', $categories])->andFilterWhere(['status' => 10])->orderBy(['id' => SORT_DESC])->limit(4)->offset($offset)->all(); return $this->render('RelatedReviewWidget', ['nodes' => $nodes]); }