private static function createCategoryRelationsTable($postTypeSlug)
    {
        if(!Schema::hasTable($postTypeSlug."_categories")) {
            Schema::create(
                $postTypeSlug."_categories", function ($table) use ($postTypeSlug) {
                    // create general fields
                    $table->bigIncrements("categoryRelationID");
                    $table->bigInteger("postID")->unsigned()->nullable();
                    $table->unsignedInteger("categoryID")->nullable();

                    $table->foreign('postID')
                        ->references('postID')->on($postTypeSlug)
                        ->onDelete('cascade');

                    $table->foreign('categoryID')
                        ->references('categoryID')->on("categories")
                        ->onDelete('cascade');

                    $table->unique(array('postID', 'categoryID'));
                }
            );
        }
    }
private static function createCategoryRelationsTable($postTypeSlug)
    {
        if(!Schema::hasTable($postTypeSlug."_categories")) {
            Schema::create(
                $postTypeSlug."_categories", function ($table) use ($postTypeSlug) {
                    // create general fields
                    $table->bigIncrements("categoryRelationID");
                    $table->bigInteger("postID")->unsigned()->nullable();
                    $table->unsignedInteger("categoryID")->nullable();

                    $table->foreign('postID')
                        ->references('postID')->on($postTypeSlug)
                        ->onDelete('cascade');

                    $table->foreign('categoryID')
                        ->references('categoryID')->on("categories")
                        ->onDelete('cascade');

                    $table->unique(array('postID', 'categoryID'));
                }
            );
        }
    }
private static function createCategoryRelationsTable ( $ postTypeSlug ) { if ( ! Schema :: hasTable ( $ postTypeSlug . "_categories" ) ) { Schema :: create ( $ postTypeSlug . "_categories" , function ( $ table ) use ( $ postTypeSlug ) { // create general fields $ table -> bigIncrements ( "categoryRelationID" ) ; $ table -> bigInteger ( "postID" ) -> unsigned ( ) -> nullable ( ) ; $ table -> unsignedInteger ( "categoryID" ) -> nullable ( ) ; $ table -> foreign ( 'postID' ) -> references ( 'postID' ) -> on ( $ postTypeSlug ) -> onDelete ( 'cascade' ) ; $ table -> foreign ( 'categoryID' ) -> references ( 'categoryID' ) -> on ( "categories" ) -> onDelete ( 'cascade' ) ; $ table -> unique ( array ( 'postID' , 'categoryID' ) ) ; } ) ; } }
Creates category relations table for the selected Post Type

@param $postTypeSlug
Creates category relations table for the selected Post Type