public function getTree($lang = "", $postTypeID)
    {
        $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'order';
        $orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'ASC';
        $parentList = Category::where('postTypeID', $postTypeID)->where('parentID', null)
            ->orWhere('parentID', 0)
            ->orderBy($orderBy, $orderType)
            ->paginate(Category::$rowsPerPage);

        $category = new Category();

        // get all categories of the selected post type
        $category->categoryList = Category::where('postTypeID', $postTypeID)
            ->orderBy($orderBy, $orderType)
            ->select("categoryID", "title", "slug")
            ->get();
        
        // make the parent child format tree
        $treeList = collect($category->makeChildrenTree($category->categoryList));

        // get only categories selected for this page (pagination)
        $tmp = [];
        foreach($parentList->items() as $item){
            $getCategory = $treeList->where('categoryID', $item->categoryID)->first();
            if($getCategory) {
                $tmp[] = $getCategory;
            }
        }

        $parentList->setCollection(collect($tmp));
        return Language::filterRows($parentList);
    }
public function getTree($lang = "", $postTypeID)
    {
        $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'order';
        $orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'ASC';
        $parentList = Category::where('postTypeID', $postTypeID)->where('parentID', null)
            ->orWhere('parentID', 0)
            ->orderBy($orderBy, $orderType)
            ->paginate(Category::$rowsPerPage);

        $category = new Category();

        // get all categories of the selected post type
        $category->categoryList = Category::where('postTypeID', $postTypeID)
            ->orderBy($orderBy, $orderType)
            ->select("categoryID", "title", "slug")
            ->get();
        
        // make the parent child format tree
        $treeList = collect($category->makeChildrenTree($category->categoryList));

        // get only categories selected for this page (pagination)
        $tmp = [];
        foreach($parentList->items() as $item){
            $getCategory = $treeList->where('categoryID', $item->categoryID)->first();
            if($getCategory) {
                $tmp[] = $getCategory;
            }
        }

        $parentList->setCollection(collect($tmp));
        return Language::filterRows($parentList);
    }
public function getTree ( $ lang = "" , $ postTypeID ) { $ orderBy = ( isset ( $ _GET [ 'order' ] ) ) ? $ orderBy = $ _GET [ 'order' ] : 'order' ; $ orderType = ( isset ( $ _GET [ 'type' ] ) ) ? $ orderType = $ _GET [ 'type' ] : 'ASC' ; $ parentList = Category :: where ( 'postTypeID' , $ postTypeID ) -> where ( 'parentID' , null ) -> orWhere ( 'parentID' , 0 ) -> orderBy ( $ orderBy , $ orderType ) -> paginate ( Category :: $ rowsPerPage ) ; $ category = new Category ( ) ; // get all categories of the selected post type $ category -> categoryList = Category :: where ( 'postTypeID' , $ postTypeID ) -> orderBy ( $ orderBy , $ orderType ) -> select ( "categoryID" , "title" , "slug" ) -> get ( ) ; // make the parent child format tree $ treeList = collect ( $ category -> makeChildrenTree ( $ category -> categoryList ) ) ; // get only categories selected for this page (pagination) $ tmp = [ ] ; foreach ( $ parentList -> items ( ) as $ item ) { $ getCategory = $ treeList -> where ( 'categoryID' , $ item -> categoryID ) -> first ( ) ; if ( $ getCategory ) { $ tmp [ ] = $ getCategory ; } } $ parentList -> setCollection ( collect ( $ tmp ) ) ; return Language :: filterRows ( $ parentList ) ; }
Gets categories by post type with parent child relations.

@param  string $lang
@param  int    $postTypeID
@return array
Gets categories by post type with parent child relations .