root_id); $categories = $rootCategory->getAllChildren(2, [], 'categoryName')->all(); $populary = []; foreach($categories as $category) { if ($category->populary) { $populary[] = $category; } } return $this->render('submenu', [ 'rootCategory' => $rootCategory, 'rootClass' => $this->rootClass, 'populary' => $populary, 'items' => $rootCategory->buildTree($categories, $rootCategory->category_id) ]); } }