public function renderCreateColumns()
    {
        $columns = $this->getTableColumns();

        if (!$columns) {
            return '';
        }

        $source = '';

        foreach ($columns as $column) {
            $attributes = [$this->serializeArrayToAttributes($column->getName())];
            $type       = $column->getType()->getName();

            switch ($type) {
                case Type::INTEGER:
                    $method = 'integer';
                    break;
                case Type::SMALLINT:
                    $method = 'smallInteger';
                    break;
                case Type::BIGINT:
                    $method = 'bigInteger';
                    break;
                case Type::STRING:
                    $attributes[] = $column->getLength();
                    $method       = 'string';
                    break;
                case Type::GUID:
                case Type::TEXT:
                    $method = 'text';
                    break;
                case Type::FLOAT:
                    $method = 'float';
                    break;
                case Type::DECIMAL:
                    $attributes[] = $column->getPrecision();
                    $attributes[] = $column->getScale();
                    $method       = 'decimal';
                    break;
                case Type::BOOLEAN:
                    $method = 'boolean';
                    break;
                case Type::DATETIME:
                case Type::DATETIMETZ:
                    $method = 'dateTime';
                    break;
                case Type::DATE:
                    $method = 'date';
                    break;
                case Type::TIME:
                    $method = 'time';
                    break;
                case Type::BINARY:
                case Type::BLOB:
                    $method = 'binary';
                    break;
                case Type::JSON_ARRAY:
                    $method = 'json';
                    break;
                default:
                    throw new DbExporterException('Not supported database column type' . $type);
                    break;
            }

            $source .= '$table->' . $method . '(' . implode(', ', $attributes) . ')';
            if ($column->getUnsigned()) {
                $source .= "\n" . '      ->unsigned()';
            }
            if (!$column->getNotnull()) {
                $source .= "\n" . '      ->nullable()';
            }
            if ($column->getDefault() || $column->getDefault() === null && !$column->getNotnull()) {
                $source .= "\n" . '      ->default(' . var_export($column->getDefault(), true) . ')';
            }
            $source .= ';' . "\n";
        }

        return trim($source);
    }
public function renderCreateColumns()
    {
        $columns = $this->getTableColumns();

        if (!$columns) {
            return '';
        }

        $source = '';

        foreach ($columns as $column) {
            $attributes = [$this->serializeArrayToAttributes($column->getName())];
            $type       = $column->getType()->getName();

            switch ($type) {
                case Type::INTEGER:
                    $method = 'integer';
                    break;
                case Type::SMALLINT:
                    $method = 'smallInteger';
                    break;
                case Type::BIGINT:
                    $method = 'bigInteger';
                    break;
                case Type::STRING:
                    $attributes[] = $column->getLength();
                    $method       = 'string';
                    break;
                case Type::GUID:
                case Type::TEXT:
                    $method = 'text';
                    break;
                case Type::FLOAT:
                    $method = 'float';
                    break;
                case Type::DECIMAL:
                    $attributes[] = $column->getPrecision();
                    $attributes[] = $column->getScale();
                    $method       = 'decimal';
                    break;
                case Type::BOOLEAN:
                    $method = 'boolean';
                    break;
                case Type::DATETIME:
                case Type::DATETIMETZ:
                    $method = 'dateTime';
                    break;
                case Type::DATE:
                    $method = 'date';
                    break;
                case Type::TIME:
                    $method = 'time';
                    break;
                case Type::BINARY:
                case Type::BLOB:
                    $method = 'binary';
                    break;
                case Type::JSON_ARRAY:
                    $method = 'json';
                    break;
                default:
                    throw new DbExporterException('Not supported database column type' . $type);
                    break;
            }

            $source .= '$table->' . $method . '(' . implode(', ', $attributes) . ')';
            if ($column->getUnsigned()) {
                $source .= "\n" . '      ->unsigned()';
            }
            if (!$column->getNotnull()) {
                $source .= "\n" . '      ->nullable()';
            }
            if ($column->getDefault() || $column->getDefault() === null && !$column->getNotnull()) {
                $source .= "\n" . '      ->default(' . var_export($column->getDefault(), true) . ')';
            }
            $source .= ';' . "\n";
        }

        return trim($source);
    }
public function renderCreateColumns ( ) { $ columns = $ this -> getTableColumns ( ) ; if ( ! $ columns ) { return '' ; } $ source = '' ; foreach ( $ columns as $ column ) { $ attributes = [ $ this -> serializeArrayToAttributes ( $ column -> getName ( ) ) ] ; $ type = $ column -> getType ( ) -> getName ( ) ; switch ( $ type ) { case Type :: INTEGER : $ method = 'integer' ; break ; case Type :: SMALLINT : $ method = 'smallInteger' ; break ; case Type :: BIGINT : $ method = 'bigInteger' ; break ; case Type :: STRING : $ attributes [ ] = $ column -> getLength ( ) ; $ method = 'string' ; break ; case Type :: GUID : case Type :: TEXT : $ method = 'text' ; break ; case Type :: FLOAT : $ method = 'float' ; break ; case Type :: DECIMAL : $ attributes [ ] = $ column -> getPrecision ( ) ; $ attributes [ ] = $ column -> getScale ( ) ; $ method = 'decimal' ; break ; case Type :: BOOLEAN : $ method = 'boolean' ; break ; case Type :: DATETIME : case Type :: DATETIMETZ : $ method = 'dateTime' ; break ; case Type :: DATE : $ method = 'date' ; break ; case Type :: TIME : $ method = 'time' ; break ; case Type :: BINARY : case Type :: BLOB : $ method = 'binary' ; break ; case Type :: JSON_ARRAY : $ method = 'json' ; break ; default : throw new DbExporterException ( 'Not supported database column type' . $ type ) ; break ; } $ source .= '$table->' . $ method . '(' . implode ( ', ' , $ attributes ) . ')' ; if ( $ column -> getUnsigned ( ) ) { $ source .= "\n" . '      ->unsigned()' ; } if ( ! $ column -> getNotnull ( ) ) { $ source .= "\n" . '      ->nullable()' ; } if ( $ column -> getDefault ( ) || $ column -> getDefault ( ) === null && ! $ column -> getNotnull ( ) ) { $ source .= "\n" . '      ->default(' . var_export ( $ column -> getDefault ( ) , true ) . ')' ; } $ source .= ';' . "\n" ; } return trim ( $ source ) ; }
Render table columns create schema builder methods

@return string

@throws \ViKon\DbExporter\Exception\DbExporterException
Render table columns create schema builder methods