src/Database/Migration.php
public static function addColumns($tableName, array $columnDefinitions)
    {
        return [
            'up' => function (Builder $schema) use ($tableName, $columnDefinitions) {
                $schema->table($tableName, function (Blueprint $table) use ($schema, $columnDefinitions) {
                    foreach ($columnDefinitions as $columnName => $options) {
                        $type = array_shift($options);
                        $table->addColumn($type, $columnName, $options);
                    }
                });
            },
            'down' => function (Builder $schema) use ($tableName, $columnDefinitions) {
                $schema->table($tableName, function (Blueprint $table) use ($columnDefinitions) {
                    $table->dropColumn(array_keys($columnDefinitions));
                });
            }
        ];
    }
public static function addColumns($tableName, array $columnDefinitions)
    {
        return [
            'up' => function (Builder $schema) use ($tableName, $columnDefinitions) {
                $schema->table($tableName, function (Blueprint $table) use ($schema, $columnDefinitions) {
                    foreach ($columnDefinitions as $columnName => $options) {
                        $type = array_shift($options);
                        $table->addColumn($type, $columnName, $options);
                    }
                });
            },
            'down' => function (Builder $schema) use ($tableName, $columnDefinitions) {
                $schema->table($tableName, function (Blueprint $table) use ($columnDefinitions) {
                    $table->dropColumn(array_keys($columnDefinitions));
                });
            }
        ];
    }
public static function addColumns ( $ tableName , array $ columnDefinitions ) { return [ 'up' => function ( Builder $ schema ) use ( $ tableName , $ columnDefinitions ) { $ schema -> table ( $ tableName , function ( Blueprint $ table ) use ( $ schema , $ columnDefinitions ) { foreach ( $ columnDefinitions as $ columnName => $ options ) { $ type = array_shift ( $ options ) ; $ table -> addColumn ( $ type , $ columnName , $ options ) ; } } ) ; } , 'down' => function ( Builder $ schema ) use ( $ tableName , $ columnDefinitions ) { $ schema -> table ( $ tableName , function ( Blueprint $ table ) use ( $ columnDefinitions ) { $ table -> dropColumn ( array_keys ( $ columnDefinitions ) ) ; } ) ; } ] ; }
Add columns to a table.
Add columns to a table .