src/Utils/TableFieldsGenerator.php
private function detectManyToOne($tables, $modelTable)
    {
        $manyToOneRelations = [];

        $foreignKeys = $modelTable->foreignKeys;

        foreach ($foreignKeys as $foreignKey) {
            $foreignTable = $foreignKey->foreignTable;
            $foreignField = $foreignKey->foreignField;

            if (!isset($tables[$foreignTable])) {
                continue;
            }

            if ($foreignField == $tables[$foreignTable]->primaryKey) {
                $modelName = model_name_from_table_name($foreignTable);
                $manyToOneRelations[] = GeneratorFieldRelation::parseRelation('mt1,'.$modelName);
            }
        }

        return $manyToOneRelations;
    }
private function detectManyToOne($tables, $modelTable)
    {
        $manyToOneRelations = [];

        $foreignKeys = $modelTable->foreignKeys;

        foreach ($foreignKeys as $foreignKey) {
            $foreignTable = $foreignKey->foreignTable;
            $foreignField = $foreignKey->foreignField;

            if (!isset($tables[$foreignTable])) {
                continue;
            }

            if ($foreignField == $tables[$foreignTable]->primaryKey) {
                $modelName = model_name_from_table_name($foreignTable);
                $manyToOneRelations[] = GeneratorFieldRelation::parseRelation('mt1,'.$modelName);
            }
        }

        return $manyToOneRelations;
    }
private function detectManyToOne ( $ tables , $ modelTable ) { $ manyToOneRelations = [ ] ; $ foreignKeys = $ modelTable -> foreignKeys ; foreach ( $ foreignKeys as $ foreignKey ) { $ foreignTable = $ foreignKey -> foreignTable ; $ foreignField = $ foreignKey -> foreignField ; if ( ! isset ( $ tables [ $ foreignTable ] ) ) { continue ; } if ( $ foreignField == $ tables [ $ foreignTable ] -> primaryKey ) { $ modelName = model_name_from_table_name ( $ foreignTable ) ; $ manyToOneRelations [ ] = GeneratorFieldRelation :: parseRelation ( 'mt1,' . $ modelName ) ; } } return $ manyToOneRelations ; }
Detect many to one relationship on model table
If foreign key of model table is primary key of foreign table.

@param GeneratorTable[] $tables
@param GeneratorTable   $modelTable

@return array
Detect many to one relationship on model table If foreign key of model table is primary key of foreign table .