public static function updateTable($postTypeSlug, $fields, $hasTags = false, $hasCategories = false)
    {
        self::$customFieldsArray = [];

        Schema::table(
            $postTypeSlug, function ($table) use ($fields) {
                $post = new Post();
                $usedSlugs = [];
                $usedSlugs = array_merge($usedSlugs, $post->fillable);

                foreach($fields as $field){
                    // generate unique slugs for every field
                    if(!isset($field['slug']) || $field['slug'] == "") {
                        $slug = self::generateSlug($field['name'], $usedSlugs);
                    }else{
                        $slug = self::generateSlug($field['slug'], $usedSlugs);
                    }
                    $usedSlugs[] = $slug;

                    $field['slug'] = $slug;

                    self::createDatabaseFields($table, $field, $slug, false);

                    // unset the canBeRemoved from array
                    if(isset($field['canBeRemoved']) && $field['canBeRemoved'] == true) {
                        unset($field['canBeRemoved']);
                    }

                    array_push(self::$customFieldsArray, $field);
                }
            }
        );

        if($hasCategories) {
            self::createCategoryRelationsTable($postTypeSlug);
        }

        if($hasTags) {
            self::createTagRelationsTable($postTypeSlug);
        }

        return self::$customFieldsArray;
    }
public static function updateTable($postTypeSlug, $fields, $hasTags = false, $hasCategories = false)
    {
        self::$customFieldsArray = [];

        Schema::table(
            $postTypeSlug, function ($table) use ($fields) {
                $post = new Post();
                $usedSlugs = [];
                $usedSlugs = array_merge($usedSlugs, $post->fillable);

                foreach($fields as $field){
                    // generate unique slugs for every field
                    if(!isset($field['slug']) || $field['slug'] == "") {
                        $slug = self::generateSlug($field['name'], $usedSlugs);
                    }else{
                        $slug = self::generateSlug($field['slug'], $usedSlugs);
                    }
                    $usedSlugs[] = $slug;

                    $field['slug'] = $slug;

                    self::createDatabaseFields($table, $field, $slug, false);

                    // unset the canBeRemoved from array
                    if(isset($field['canBeRemoved']) && $field['canBeRemoved'] == true) {
                        unset($field['canBeRemoved']);
                    }

                    array_push(self::$customFieldsArray, $field);
                }
            }
        );

        if($hasCategories) {
            self::createCategoryRelationsTable($postTypeSlug);
        }

        if($hasTags) {
            self::createTagRelationsTable($postTypeSlug);
        }

        return self::$customFieldsArray;
    }
public static function updateTable ( $ postTypeSlug , $ fields , $ hasTags = false , $ hasCategories = false ) { self :: $ customFieldsArray = [ ] ; Schema :: table ( $ postTypeSlug , function ( $ table ) use ( $ fields ) { $ post = new Post ( ) ; $ usedSlugs = [ ] ; $ usedSlugs = array_merge ( $ usedSlugs , $ post -> fillable ) ; foreach ( $ fields as $ field ) { // generate unique slugs for every field if ( ! isset ( $ field [ 'slug' ] ) || $ field [ 'slug' ] == "" ) { $ slug = self :: generateSlug ( $ field [ 'name' ] , $ usedSlugs ) ; } else { $ slug = self :: generateSlug ( $ field [ 'slug' ] , $ usedSlugs ) ; } $ usedSlugs [ ] = $ slug ; $ field [ 'slug' ] = $ slug ; self :: createDatabaseFields ( $ table , $ field , $ slug , false ) ; // unset the canBeRemoved from array if ( isset ( $ field [ 'canBeRemoved' ] ) && $ field [ 'canBeRemoved' ] == true ) { unset ( $ field [ 'canBeRemoved' ] ) ; } array_push ( self :: $ customFieldsArray , $ field ) ; } } ) ; if ( $ hasCategories ) { self :: createCategoryRelationsTable ( $ postTypeSlug ) ; } if ( $ hasTags ) { self :: createTagRelationsTable ( $ postTypeSlug ) ; } return self :: $ customFieldsArray ; }
Update post type table and add new columns.

@param  $postTypeSlug
@param  $fields
@return array
Update post type table and add new columns .