public function renderCreateForeignKeys()
    {
        $foreignKeys = $this->getTableForeignKeys();

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

        $source = '';
        foreach ($foreignKeys as $foreignKey) {
            $name             = $this->serializeIndexNameToAttribute($foreignKey->getName());
            $localColumns     = $this->serializeArrayToAttributes($foreignKey->getLocalColumns());
            $foreignColumns   = $this->serializeArrayToAttributes($foreignKey->getForeignColumns());
            $foreignTableName = '\'' . snake_case($foreignKey->getForeignTableName()) . '\'';
            $source .= "\n" . '$table->foreign(' . $localColumns . ', ' . $name . ')';
            $source .= "\n" . '      ->references(' . $foreignColumns . ')';
            $source .= "\n" . '      ->on(' . $foreignTableName . ')';
            if (($onDelete = $foreignKey->getOption('onUpdate')) !== null) {
                $onDelete = var_export($onDelete, true);
                $source .= "\n" . '      ->onUpdate(' . $onDelete . ')';
            }
            if (($onUpdate = $foreignKey->getOption('onDelete')) !== null) {
                $onUpdate = var_export($onUpdate, true);
                $source .= "\n" . '      ->onUpdate(' . $onUpdate . ')';
            }
            $source .= ';' . "\n";
        }

        return trim($source);
    }
public function renderCreateForeignKeys()
    {
        $foreignKeys = $this->getTableForeignKeys();

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

        $source = '';
        foreach ($foreignKeys as $foreignKey) {
            $name             = $this->serializeIndexNameToAttribute($foreignKey->getName());
            $localColumns     = $this->serializeArrayToAttributes($foreignKey->getLocalColumns());
            $foreignColumns   = $this->serializeArrayToAttributes($foreignKey->getForeignColumns());
            $foreignTableName = '\'' . snake_case($foreignKey->getForeignTableName()) . '\'';
            $source .= "\n" . '$table->foreign(' . $localColumns . ', ' . $name . ')';
            $source .= "\n" . '      ->references(' . $foreignColumns . ')';
            $source .= "\n" . '      ->on(' . $foreignTableName . ')';
            if (($onDelete = $foreignKey->getOption('onUpdate')) !== null) {
                $onDelete = var_export($onDelete, true);
                $source .= "\n" . '      ->onUpdate(' . $onDelete . ')';
            }
            if (($onUpdate = $foreignKey->getOption('onDelete')) !== null) {
                $onUpdate = var_export($onUpdate, true);
                $source .= "\n" . '      ->onUpdate(' . $onUpdate . ')';
            }
            $source .= ';' . "\n";
        }

        return trim($source);
    }
public function renderCreateForeignKeys ( ) { $ foreignKeys = $ this -> getTableForeignKeys ( ) ; if ( ! $ foreignKeys ) { return '' ; } $ source = '' ; foreach ( $ foreignKeys as $ foreignKey ) { $ name = $ this -> serializeIndexNameToAttribute ( $ foreignKey -> getName ( ) ) ; $ localColumns = $ this -> serializeArrayToAttributes ( $ foreignKey -> getLocalColumns ( ) ) ; $ foreignColumns = $ this -> serializeArrayToAttributes ( $ foreignKey -> getForeignColumns ( ) ) ; $ foreignTableName = '\'' . snake_case ( $ foreignKey -> getForeignTableName ( ) ) . '\'' ; $ source .= "\n" . '$table->foreign(' . $ localColumns . ', ' . $ name . ')' ; $ source .= "\n" . '      ->references(' . $ foreignColumns . ')' ; $ source .= "\n" . '      ->on(' . $ foreignTableName . ')' ; if ( ( $ onDelete = $ foreignKey -> getOption ( 'onUpdate' ) ) !== null ) { $ onDelete = var_export ( $ onDelete , true ) ; $ source .= "\n" . '      ->onUpdate(' . $ onDelete . ')' ; } if ( ( $ onUpdate = $ foreignKey -> getOption ( 'onDelete' ) ) !== null ) { $ onUpdate = var_export ( $ onUpdate , true ) ; $ source .= "\n" . '      ->onUpdate(' . $ onUpdate . ')' ; } $ source .= ';' . "\n" ; } return trim ( $ source ) ; }
Render table foreign keys create schema builder methods

@return string
Render table foreign keys create schema builder methods