Laralib\L5scaffold\Migrations\SyntaxBuilder::createSchemaForDownMethod PHP Метод

createSchemaForDownMethod() приватный Метод

Construct the syntax for a down field.
private createSchemaForDownMethod ( array $schema, array $meta ) : string
$schema array
$meta array
Результат string
    private function createSchemaForDownMethod($schema, $meta)
    {
        // If the user created a table, then for the down
        // method, we should drop it.
        if ($meta['action'] == 'create') {
            return sprintf("Schema::drop('%s');", $meta['table']);
        }
        // If the user added columns to a table, then for
        // the down method, we should remove them.
        if ($meta['action'] == 'add') {
            $fields = $this->constructSchema($schema, 'Drop');
            return $this->insert($fields)->into($this->getChangeSchemaWrapper());
        }
        // If the user removed columns from a table, then for
        // the down method, we should add them back on.
        if ($meta['action'] == 'remove') {
            $fields = $this->constructSchema($schema);
            return $this->insert($fields)->into($this->getChangeSchemaWrapper());
        }
        // Otherwise, we have no idea how to proceed.
        throw new GeneratorException();
    }