/** * Возвращает список возможных категорий товара. * Примечание: используется в backend/user/index представлении. * * @return mixed */ public static function getCategoryList() { $categories = []; foreach (Category::getCategory() as $item_name) { $categories[$item_name->id] = $item_name->name; } return $categories; }
/** * @expectedException \yii\web\NotFoundHttpException */ public function testGetCategoryNotFound() { $this->assertInstanceOf('common\\models\\Category', $this->categoryModel->getCategory(-1)); }
public function actionView($id) { $categoryModel = new Category(); $category = $categoryModel->getCategory($id); return $this->render('index', ['category' => $category, 'posts' => $category->getPosts(), 'categories' => $categoryModel->getCategories()]); }