protected function checkPivotTable($table)
    {
        $pk = $table->primaryKey;
        if (count($pk) !== 2) {
            return false;
        }
        $fks = [];
        foreach ($table->foreignKeys as $refs) {
            if (count($refs) === 2) {
                if (isset($refs[$pk[0]])) {
                    $fks[$pk[0]] = [$refs[0], $refs[$pk[0]]];
                } elseif (isset($refs[$pk[1]])) {
                    $fks[$pk[1]] = [$refs[0], $refs[$pk[1]]];
                }
            }
        }
        if (count($fks) === 2 && $fks[$pk[0]][0] !== $fks[$pk[1]][0]) {
            return $fks;
        } else {
            return false;
        }
    }
protected function checkPivotTable($table)
    {
        $pk = $table->primaryKey;
        if (count($pk) !== 2) {
            return false;
        }
        $fks = [];
        foreach ($table->foreignKeys as $refs) {
            if (count($refs) === 2) {
                if (isset($refs[$pk[0]])) {
                    $fks[$pk[0]] = [$refs[0], $refs[$pk[0]]];
                } elseif (isset($refs[$pk[1]])) {
                    $fks[$pk[1]] = [$refs[0], $refs[$pk[1]]];
                }
            }
        }
        if (count($fks) === 2 && $fks[$pk[0]][0] !== $fks[$pk[1]][0]) {
            return $fks;
        } else {
            return false;
        }
    }
protected function checkPivotTable ( $ table ) { $ pk = $ table -> primaryKey ; if ( count ( $ pk ) !== 2 ) { return false ; } $ fks = [ ] ; foreach ( $ table -> foreignKeys as $ refs ) { if ( count ( $ refs ) === 2 ) { if ( isset ( $ refs [ $ pk [ 0 ] ] ) ) { $ fks [ $ pk [ 0 ] ] = [ $ refs [ 0 ] , $ refs [ $ pk [ 0 ] ] ] ; } elseif ( isset ( $ refs [ $ pk [ 1 ] ] ) ) { $ fks [ $ pk [ 1 ] ] = [ $ refs [ 0 ] , $ refs [ $ pk [ 1 ] ] ] ; } } } if ( count ( $ fks ) === 2 && $ fks [ $ pk [ 0 ] ] [ 0 ] !== $ fks [ $ pk [ 1 ] ] [ 0 ] ) { return $ fks ; } else { return false ; } }
Checks if the given table is a junction table.
For simplicity, this method only deals with the case where the pivot contains two PK columns,
each referencing a column in a different table.
@param TableSchema the table being checked
@param TableSchema $table
@return array|boolean the relevant foreign key constraint information if the table is a junction table,
or false if the table is not a junction table.
Checks if the given table is a junction table . For simplicity this method only deals with the case where the pivot contains two PK columns each referencing a column in a different table .