/** * Displays a single Category model. * @param integer $id * @return mixed */ public function actionView($id) { $categoryModel = new Category(); $category = $categoryModel->getCategory($id); return $this->render('index', ['category' => $category, 'posts' => $category->getPosts(), 'categories' => $categoryModel->getCategories()]); }
public function init() { parent::init(); $this->categoryArr = Category::getCategories(); }
/** * Список постов. * @return string */ public function actionIndex() { $post = new Post(); $category = new Category(); return $this->render('index', ['posts' => $post->getPublishedPosts(), 'categories' => $category->getCategories()]); }