source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php
protected function findOuter(SchemaBuilder $builder)
    {
        foreach ($this->findTargets($builder) as $schema) {
            $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());
            $outerKey = $this->option(Record::OUTER_KEY);

            if ($outerKey == ORMInterface::R_PRIMARY_KEY) {
                $outerKey = current($outerTable->getPrimaryKeys());
            }

            if (!$outerTable->hasColumn($outerKey)) {
                throw new RelationSchemaException(sprintf("Outer key '%s'.'%s' (%s) does not exists",
                    $outerTable->getName(),
                    $outerKey,
                    $this->getDefinition()->getName()
                ));
            }

            return $outerTable->column($outerKey);
        }

        return null;
    }
protected function findOuter(SchemaBuilder $builder)
    {
        foreach ($this->findTargets($builder) as $schema) {
            $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());
            $outerKey = $this->option(Record::OUTER_KEY);

            if ($outerKey == ORMInterface::R_PRIMARY_KEY) {
                $outerKey = current($outerTable->getPrimaryKeys());
            }

            if (!$outerTable->hasColumn($outerKey)) {
                throw new RelationSchemaException(sprintf("Outer key '%s'.'%s' (%s) does not exists",
                    $outerTable->getName(),
                    $outerKey,
                    $this->getDefinition()->getName()
                ));
            }

            return $outerTable->column($outerKey);
        }

        return null;
    }
protected function findOuter ( SchemaBuilder $ builder ) { foreach ( $ this -> findTargets ( $ builder ) as $ schema ) { $ outerTable = $ builder -> requestTable ( $ schema -> getTable ( ) , $ schema -> getDatabase ( ) ) ; $ outerKey = $ this -> option ( Record :: OUTER_KEY ) ; if ( $ outerKey == ORMInterface :: R_PRIMARY_KEY ) { $ outerKey = current ( $ outerTable -> getPrimaryKeys ( ) ) ; } if ( ! $ outerTable -> hasColumn ( $ outerKey ) ) { throw new RelationSchemaException ( sprintf ( "Outer key '%s'.'%s' (%s) does not exists" , $ outerTable -> getName ( ) , $ outerKey , $ this -> getDefinition ( ) -> getName ( ) ) ) ; } return $ outerTable -> column ( $ outerKey ) ; } return null ; }
Resolving outer key.

@param \Spiral\ORM\Schemas\SchemaBuilder $builder

@return \Spiral\Database\Schemas\Prototypes\AbstractColumn|null When no outer records found
NULL will be returned.
Resolving outer key .