private function deleteCategory(int $id)
    {
        $category = Category::find($id);
        if($category) {
            $postType = PostType::findByID($category->postTypeID);
            if(Category::isInMenuLinks($id)) {
                return $this->response("You can't delete this Category. It is part of a menu", 403);
            }

            // delete children
            $category->deleteChildren($category->categoryID, $postType->postTypeID);

            // delete relations
            DB::table(categoriesRelationTable($postType->slug))->where("categoryID", $category->categoryID)->delete();

            // Delete the item
            if($category->delete()) {
                return true;
            }
        }
        return false;
    }
private function deleteCategory(int $id)
    {
        $category = Category::find($id);
        if($category) {
            $postType = PostType::findByID($category->postTypeID);
            if(Category::isInMenuLinks($id)) {
                return $this->response("You can't delete this Category. It is part of a menu", 403);
            }

            // delete children
            $category->deleteChildren($category->categoryID, $postType->postTypeID);

            // delete relations
            DB::table(categoriesRelationTable($postType->slug))->where("categoryID", $category->categoryID)->delete();

            // Delete the item
            if($category->delete()) {
                return true;
            }
        }
        return false;
    }
private function deleteCategory ( int $ id ) { $ category = Category :: find ( $ id ) ; if ( $ category ) { $ postType = PostType :: findByID ( $ category -> postTypeID ) ; if ( Category :: isInMenuLinks ( $ id ) ) { return $ this -> response ( "You can't delete this Category. It is part of a menu" , 403 ) ; } // delete children $ category -> deleteChildren ( $ category -> categoryID , $ postType -> postTypeID ) ; // delete relations DB :: table ( categoriesRelationTable ( $ postType -> slug ) ) -> where ( "categoryID" , $ category -> categoryID ) -> delete ( ) ; // Delete the item if ( $ category -> delete ( ) ) { return true ; } } return false ; }
Delete single category and all its children.

@param  int $id
@return array|bool
@throws \Exception
Delete single category and all its children .