mootensai\enhancedgii\crud\Generator::getNameAttributeFK PHP Method

getNameAttributeFK() public method

public getNameAttributeFK ( $tableName )
    public function getNameAttributeFK($tableName)
    {
        $tableSchema = $this->getDbConnection()->getTableSchema($tableName);
        foreach ($tableSchema->getColumnNames() as $name) {
            if (in_array($name, $this->nameAttribute) || $name === $tableName) {
                return $name;
            }
        }
        $pk = empty($tableSchema->primaryKey) ? $tableSchema->getColumnNames()[0] : $tableSchema->primaryKey[0];
        return $pk;
    }