src/FieldHandlers/RelatedFieldTrait.php
protected function _getForeignKey(Table $table, string $modelName) : string
    {
        foreach ($table->associations() as $association) {
            if ($modelName !== $association->className()) {
                continue;
            }

            $primaryKey = $association->getForeignKey();
            if (! is_string($primaryKey)) {
                throw new RuntimeException('Primary key must be a string');
            }

            return $primaryKey;
        }

        return '';
    }
protected function _getForeignKey(Table $table, string $modelName) : string
    {
        foreach ($table->associations() as $association) {
            if ($modelName !== $association->className()) {
                continue;
            }

            $primaryKey = $association->getForeignKey();
            if (! is_string($primaryKey)) {
                throw new RuntimeException('Primary key must be a string');
            }

            return $primaryKey;
        }

        return '';
    }
protected function _getForeignKey ( Table $ table , string $ modelName ) : string { foreach ( $ table -> associations ( ) as $ association ) { if ( $ modelName !== $ association -> className ( ) ) { continue ; } $ primaryKey = $ association -> getForeignKey ( ) ; if ( ! is_string ( $ primaryKey ) ) { throw new RuntimeException ( 'Primary key must be a string' ) ; } return $ primaryKey ; } return '' ; }
Get parent model association's foreign key.

@param \Cake\ORM\Table $table Table instance
@param string $modelName Model name
@return string
Get parent model association s foreign key .