src/Database/Migration.php
/**
     * Add columns to a table.
     */
Add columns to a table.
Add columns to a table .
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);
                    }
                    Migration::fixIndexNames($schema, $table);
                });
            },
            '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 ) ; } Migration :: fixIndexNames ( $ schema , $ table ) ; } ) ; } , '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 .