0 follower

Final Class Yiisoft\Yii\Gii\Generator\ActiveRecord\Relation

InheritanceYiisoft\Yii\Gii\Generator\ActiveRecord\Relation

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Yiisoft\Db\Schema\TableSchemaInterface $tableSchema, string[] $columnNames, \Yiisoft\Db\Schema\TableSchemaInterface $foreignTableSchema, string[] $foreignColumnNames )
$tableSchema \Yiisoft\Db\Schema\TableSchemaInterface
$columnNames string[]
$foreignTableSchema \Yiisoft\Db\Schema\TableSchemaInterface
$foreignColumnNames string[]

                public function __construct(
    private readonly TableSchemaInterface $tableSchema,
    private readonly array $columnNames,
    private readonly TableSchemaInterface $foreignTableSchema,
    private readonly array $foreignColumnNames,
) {}

            
getGetterMethodName() public method

Returns the method name for the relation getter (e.g., "getProfile").

public string getGetterMethodName ( )

                public function getGetterMethodName(): string
{
    return 'get' . ucfirst($this->getName());
}

            
getGetterReturnType() public method

Returns the return type for the getter method.

public string getGetterReturnType ( )

                public function getGetterReturnType(): string
{
    if (!$this->isUniqueForeignColumns()) {
        return 'array';
    }
    return '?' . $this->getRelatedModel();
}

            
getInverseOf() public method

public string getInverseOf ( )

                public function getInverseOf(): string
{
    return ArHelper::getRelationName(
        $this->foreignColumnNames,
        $this->tableSchema->getName(),
        $this->isUniqueColumns(),
    );
}

            
getLink() public method

public string[] getLink ( )

getName() public method

public string getName ( )

                public function getName(): string
{
    return $this->name ??= ArHelper::getRelationName(
        $this->columnNames,
        $this->foreignTableSchema->getName(),
        $this->isUniqueForeignColumns(),
    );
}

            
getQueryMethodName() public method

Returns the method name for the relation query (e.g., "getProfileQuery").

public string getQueryMethodName ( )

                public function getQueryMethodName(): string
{
    return $this->getGetterMethodName() . 'Query';
}

            
getRelatedModel() public method

public string getRelatedModel ( )

                public function getRelatedModel(): string
{
    $foreignTableName = $this->foreignTableSchema->getName();
    return (new Inflector())->tableToClass($foreignTableName);
}

            
getRelationMethod() public method

Returns relation method name.

public string getRelationMethod ( )

                public function getRelationMethod(): string
{
    return $this->isUniqueForeignColumns() ? 'hasOne' : 'hasMany';
}