protected function buildTableDefinition(DialectInterface $grammar)
    {
        // Manage primary key / multiple primary keys
        $primaries = [];

        // Extract defined primary index
        foreach ($this->indexes as $key => $index) {
            if ($index->get('type') == 'PRIMARY') {
                foreach ($index->get('columns') as $column) {
                    $this->columns[$column]->primary();
                }

                unset($this->indexes[$key]);
            }
        }

        // Extract defined primary column
        foreach ($this->columns as $column) {
            if ($column->get('primary')) {
                $primaries[] = $column->get('name');

                unset($column['primary']);
            }
        }

        // Re-Build primary index
        if (($cprimaries = count($primaries)) === 1) {
            $this->columns[array_shift($primaries)]->primary();
        } elseif ($cprimaries > 0) {
            $this->primary($primaries);
        }

        // Build table definition
        $definition = [];

        foreach ($this->columns as $column) {
            $definition['columns'][] = $this->fluentToColumn($column, $grammar);
        }

        foreach ($this->indexes as $index) {
            $definition['indexes'][] = $this->fluentToIndex($index, $grammar);
        }

        foreach ($this->references as $reference) {
            $definition['references'][] = $this->fluentToReference($reference);
        }

        foreach ($this->options as $name => $value) {
            $definition['options'][strtoupper($name)] = $value;
        }

        return $definition;
    }
protected function buildTableDefinition(DialectInterface $grammar)
    {
        // Manage primary key / multiple primary keys
        $primaries = [];

        // Extract defined primary index
        foreach ($this->indexes as $key => $index) {
            if ($index->get('type') == 'PRIMARY') {
                foreach ($index->get('columns') as $column) {
                    $this->columns[$column]->primary();
                }

                unset($this->indexes[$key]);
            }
        }

        // Extract defined primary column
        foreach ($this->columns as $column) {
            if ($column->get('primary')) {
                $primaries[] = $column->get('name');

                unset($column['primary']);
            }
        }

        // Re-Build primary index
        if (($cprimaries = count($primaries)) === 1) {
            $this->columns[array_shift($primaries)]->primary();
        } elseif ($cprimaries > 0) {
            $this->primary($primaries);
        }

        // Build table definition
        $definition = [];

        foreach ($this->columns as $column) {
            $definition['columns'][] = $this->fluentToColumn($column, $grammar);
        }

        foreach ($this->indexes as $index) {
            $definition['indexes'][] = $this->fluentToIndex($index, $grammar);
        }

        foreach ($this->references as $reference) {
            $definition['references'][] = $this->fluentToReference($reference);
        }

        foreach ($this->options as $name => $value) {
            $definition['options'][strtoupper($name)] = $value;
        }

        return $definition;
    }
protected function buildTableDefinition ( DialectInterface $ grammar ) { // Manage primary key / multiple primary keys $ primaries = [ ] ; // Extract defined primary index foreach ( $ this -> indexes as $ key => $ index ) { if ( $ index -> get ( 'type' ) == 'PRIMARY' ) { foreach ( $ index -> get ( 'columns' ) as $ column ) { $ this -> columns [ $ column ] -> primary ( ) ; } unset ( $ this -> indexes [ $ key ] ) ; } } // Extract defined primary column foreach ( $ this -> columns as $ column ) { if ( $ column -> get ( 'primary' ) ) { $ primaries [ ] = $ column -> get ( 'name' ) ; unset ( $ column [ 'primary' ] ) ; } } // Re-Build primary index if ( ( $ cprimaries = count ( $ primaries ) ) === 1 ) { $ this -> columns [ array_shift ( $ primaries ) ] -> primary ( ) ; } elseif ( $ cprimaries > 0 ) { $ this -> primary ( $ primaries ) ; } // Build table definition $ definition = [ ] ; foreach ( $ this -> columns as $ column ) { $ definition [ 'columns' ] [ ] = $ this -> fluentToColumn ( $ column , $ grammar ) ; } foreach ( $ this -> indexes as $ index ) { $ definition [ 'indexes' ] [ ] = $ this -> fluentToIndex ( $ index , $ grammar ) ; } foreach ( $ this -> references as $ reference ) { $ definition [ 'references' ] [ ] = $ this -> fluentToReference ( $ reference ) ; } foreach ( $ this -> options as $ name => $ value ) { $ definition [ 'options' ] [ strtoupper ( $ name ) ] = $ value ; } return $ definition ; }
Build the table definition for table creation

@param \Neutrino\Database\Schema\DialectInterface $grammar

@return array
Build the table definition for table creation