public function addToMenu(Menu $menu)
    {
        if($this->postTypeID) {
            $data = [
                'menuID' => $menu->menuID,
                'belongsToID' => $this->categoryID,
                'belongsTo' => 'category',
                'params' => $this->menuLinkParameters(),
                'routeName' => 'category.posts'
            ];

            foreach (Language::all() as $language) {
                $data['slug'][$language->slug] = $this->translate($language->slug)->slug;
                $data['label'][$language->slug] = $this->title;
            }

            factory(MenuLink::class)->create($data);
        }

        return $this;
    }
public function addToMenu(Menu $menu)
    {
        if($this->postTypeID) {
            $data = [
                'menuID' => $menu->menuID,
                'belongsToID' => $this->categoryID,
                'belongsTo' => 'category',
                'params' => $this->menuLinkParameters(),
                'routeName' => 'category.posts'
            ];

            foreach (Language::all() as $language) {
                $data['slug'][$language->slug] = $this->translate($language->slug)->slug;
                $data['label'][$language->slug] = $this->title;
            }

            factory(MenuLink::class)->create($data);
        }

        return $this;
    }
public function addToMenu ( Menu $ menu ) { if ( $ this -> postTypeID ) { $ data = [ 'menuID' => $ menu -> menuID , 'belongsToID' => $ this -> categoryID , 'belongsTo' => 'category' , 'params' => $ this -> menuLinkParameters ( ) , 'routeName' => 'category.posts' ] ; foreach ( Language :: all ( ) as $ language ) { $ data [ 'slug' ] [ $ language -> slug ] = $ this -> translate ( $ language -> slug ) -> slug ; $ data [ 'label' ] [ $ language -> slug ] = $ this -> title ; } factory ( MenuLink :: class ) -> create ( $ data ) ; } return $ this ; }
Add a category to a Menu.

@param  Menu $menu
@return object
Add a category to a Menu .