Nwidart\Modules\Support\Migrations\SchemaParser::down PHP Method

down() public method

Render down migration fields.
public down ( ) : string
return string
    public function down()
    {
        $results = '';
        foreach ($this->toArray() as $column => $attributes) {
            $attributes = [head($attributes)];
            $results .= $this->createField($column, $attributes, 'remove');
        }
        return $results;
    }

Usage Example

    /** @test */
    public function it_generates_migration_methods_for_down_method()
    {
        $parser = new SchemaParser('username:string, password:integer');
        $expected = <<<TEXT
\t\t\t\$table->dropColumn('username');
\t\t\t\$table->dropColumn('password');

TEXT;
        self::assertEquals($expected, $parser->down());
    }