public function deleteChildren(int $parentID, int $postTypeID)
    {
        $this->categoryList = self::where("postTypeID", $postTypeID)->get();
        $this->getAllChildren($parentID);
        foreach($this->categoriesToBeDeleted as $cat){
            // Post type should not be able to be deleted if it has posts
            if(self::isInMenuLinks($cat->categoryID)) {
                return $this->response("You can't delete this Category because it is part of a menu.", 403);
            }

            $postType = PostType::findByID($postTypeID);
            // delete relations
            DB::table($postType->slug.'_categories')->where("categoryID", $cat->categoryID)->delete();
            // delete children
            $cat->delete();
        }
    }
public function deleteChildren(int $parentID, int $postTypeID)
    {
        $this->categoryList = self::where("postTypeID", $postTypeID)->get();
        $this->getAllChildren($parentID);
        foreach($this->categoriesToBeDeleted as $cat){
            // Post type should not be able to be deleted if it has posts
            if(self::isInMenuLinks($cat->categoryID)) {
                return $this->response("You can't delete this Category because it is part of a menu.", 403);
            }

            $postType = PostType::findByID($postTypeID);
            // delete relations
            DB::table($postType->slug.'_categories')->where("categoryID", $cat->categoryID)->delete();
            // delete children
            $cat->delete();
        }
    }
public function deleteChildren ( int $ parentID , int $ postTypeID ) { $ this -> categoryList = self :: where ( "postTypeID" , $ postTypeID ) -> get ( ) ; $ this -> getAllChildren ( $ parentID ) ; foreach ( $ this -> categoriesToBeDeleted as $ cat ) { // Post type should not be able to be deleted if it has posts if ( self :: isInMenuLinks ( $ cat -> categoryID ) ) { return $ this -> response ( "You can't delete this Category because it is part of a menu." , 403 ) ; } $ postType = PostType :: findByID ( $ postTypeID ) ; // delete relations DB :: table ( $ postType -> slug . '_categories' ) -> where ( "categoryID" , $ cat -> categoryID ) -> delete ( ) ; // delete children $ cat -> delete ( ) ; } }
Delete List of children.

@param  int $parentID
@param  int $postTypeID
@return mixed
@throws \Exception
Delete List of children .