public static function cmsMenuLinks($menuLinks = [])
    {
        $links = [];
        $count = 0;

        if($menuLinks) {
            foreach($menuLinks as $menuLink){
                if($menuLink->belongsTo == "post_type") {
                    $permission = User::hasAccess($menuLink->slug, "read");
                }elseif($menuLink->belongsTo == "category") {
                    $permission = User::hasAccess("Category", "read");
                }else{
                    $permission = User::hasAccess($menuLink->slug, "update");
                }

                $routeURL = self::getActionOfLink($menuLink);
                if($routeURL) {
                    $links[$count] = [
                        'label' => $menuLink->label,
                        'menuLinkID' => $menuLink->menuLinkID,
                        'link' => self::removeDomainFromLink($routeURL),
                        'icon' => '',
                        'access' => $permission,
                        'children' => self::cmsMenuLinks($menuLink->children),
                    ];
                    $count++;
                }
            }
        }
        if(!count($links)) {
            return [];
        }
        return $links;
    }
public static function cmsMenuLinks($menuLinks = [])
    {
        $links = [];
        $count = 0;

        if($menuLinks) {
            foreach($menuLinks as $menuLink){
                if($menuLink->belongsTo == "post_type") {
                    $permission = User::hasAccess($menuLink->slug, "read");
                }elseif($menuLink->belongsTo == "category") {
                    $permission = User::hasAccess("Category", "read");
                }else{
                    $permission = User::hasAccess($menuLink->slug, "update");
                }

                $routeURL = self::getActionOfLink($menuLink);
                if($routeURL) {
                    $links[$count] = [
                        'label' => $menuLink->label,
                        'menuLinkID' => $menuLink->menuLinkID,
                        'link' => self::removeDomainFromLink($routeURL),
                        'icon' => '',
                        'access' => $permission,
                        'children' => self::cmsMenuLinks($menuLink->children),
                    ];
                    $count++;
                }
            }
        }
        if(!count($links)) {
            return [];
        }
        return $links;
    }
public static function cmsMenuLinks ( $ menuLinks = [ ] ) { $ links = [ ] ; $ count = 0 ; if ( $ menuLinks ) { foreach ( $ menuLinks as $ menuLink ) { if ( $ menuLink -> belongsTo == "post_type" ) { $ permission = User :: hasAccess ( $ menuLink -> slug , "read" ) ; } elseif ( $ menuLink -> belongsTo == "category" ) { $ permission = User :: hasAccess ( "Category" , "read" ) ; } else { $ permission = User :: hasAccess ( $ menuLink -> slug , "update" ) ; } $ routeURL = self :: getActionOfLink ( $ menuLink ) ; if ( $ routeURL ) { $ links [ $ count ] = [ 'label' => $ menuLink -> label , 'menuLinkID' => $ menuLink -> menuLinkID , 'link' => self :: removeDomainFromLink ( $ routeURL ) , 'icon' => '' , 'access' => $ permission , 'children' => self :: cmsMenuLinks ( $ menuLink -> children ) , ] ; $ count ++ ; } } } if ( ! count ( $ links ) ) { return [ ] ; } return $ links ; }
Get MenuLinks to be shown in Admin Panel

@param  array $menuLinks
@return array
@throws \Exception
Get MenuLinks to be shown in Admin Panel