public function build(Connection $connection, Grammar $grammar)
    {
        $command = $this->parseCommand($this->commands[0]->get('name'));
        $schema  = $connection->getSchemaBuilder();

        if ($command === "drop") {
            $schema->dropIfExists($this->getI18NTableName());
        }

        parent::build($connection, $grammar);

        if ($command === "create") {
            $primary      = $this->i18n_primary;
            $i18n_columns = $this->i18n_columns;
            $table_name   = $this->table;
            $schema->create($this->getI18NTableName(), function (Blueprint $table) use ($table_name, $primary, $i18n_columns) {
                foreach ($primary as $name => $col) {
                    $table->columns[] = $col;

                    $table->foreign($col->get('name'))->references($col->get('name'))->on($table_name)->onDelete('cascade');
                }

                foreach ($i18n_columns as $col) {
                    $table->columns[] = $col;
                }

                $table->string($this->i18n_code_field, 10);
                $table->primary(array_merge(array_keys($primary), [$this->i18n_code_field]));
            });
        }
    }
public function build(Connection $connection, Grammar $grammar)
    {
        $command = $this->parseCommand($this->commands[0]->get('name'));
        $schema  = $connection->getSchemaBuilder();

        if ($command === "drop") {
            $schema->dropIfExists($this->getI18NTableName());
        }

        parent::build($connection, $grammar);

        if ($command === "create") {
            $primary      = $this->i18n_primary;
            $i18n_columns = $this->i18n_columns;
            $table_name   = $this->table;
            $schema->create($this->getI18NTableName(), function (Blueprint $table) use ($table_name, $primary, $i18n_columns) {
                foreach ($primary as $name => $col) {
                    $table->columns[] = $col;

                    $table->foreign($col->get('name'))->references($col->get('name'))->on($table_name)->onDelete('cascade');
                }

                foreach ($i18n_columns as $col) {
                    $table->columns[] = $col;
                }

                $table->string($this->i18n_code_field, 10);
                $table->primary(array_merge(array_keys($primary), [$this->i18n_code_field]));
            });
        }
    }
public function build ( Connection $ connection , Grammar $ grammar ) { $ command = $ this -> parseCommand ( $ this -> commands [ 0 ] -> get ( 'name' ) ) ; $ schema = $ connection -> getSchemaBuilder ( ) ; if ( $ command === "drop" ) { $ schema -> dropIfExists ( $ this -> getI18NTableName ( ) ) ; } parent :: build ( $ connection , $ grammar ) ; if ( $ command === "create" ) { $ primary = $ this -> i18n_primary ; $ i18n_columns = $ this -> i18n_columns ; $ table_name = $ this -> table ; $ schema -> create ( $ this -> getI18NTableName ( ) , function ( Blueprint $ table ) use ( $ table_name , $ primary , $ i18n_columns ) { foreach ( $ primary as $ name => $ col ) { $ table -> columns [ ] = $ col ; $ table -> foreign ( $ col -> get ( 'name' ) ) -> references ( $ col -> get ( 'name' ) ) -> on ( $ table_name ) -> onDelete ( 'cascade' ) ; } foreach ( $ i18n_columns as $ col ) { $ table -> columns [ ] = $ col ; } $ table -> string ( $ this -> i18n_code_field , 10 ) ; $ table -> primary ( array_merge ( array_keys ( $ primary ) , [ $ this -> i18n_code_field ] ) ) ; } ) ; } }
Overrride build function

@param Connection $connection
@param Grammar    $grammar
Overrride build function