/** * Retrieves the forum tree in a nested array * * @return array */ public function getForumTree() { $tree = array(); foreach (Category::orderBy('sort_id', 'ASC')->get() as $category) { $branch = array('name' => $category->name, 'type' => 'Category', 'sort_id' => $category->sort_id, 'id' => $category->id); $children = $category->children; if (count($children) > 0) { $branch['children'] = $this->getChildrenTree($children); } else { $branch['children'] = array(); } $tree[] = $branch; } return $tree; }
public function getAll() { return Category::orderBy('sort_id', 'ASC')->get(); }