0 follower

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

InheritanceYiisoft\Yii\Gii\Generator\ActiveRecord\InverseRelation » Yiisoft\Yii\Gii\Generator\ActiveRecord\AbstractRelation

Represents an inverse relation (incoming foreign key from another table).

For example, if a Post table has a FK to User, then User has an inverse hasMany relation to Post.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Yiisoft\Db\Constraint\ForeignKey $foreignKey, string $relatedTableName )
$foreignKey \Yiisoft\Db\Constraint\ForeignKey
$relatedTableName string

                public function __construct(
    private readonly ForeignKey $foreignKey,
    private readonly string $relatedTableName,
) {}

            
getGetterMethodName() public method

Defined in: Yiisoft\Yii\Gii\Generator\ActiveRecord\AbstractRelation::getGetterMethodName()

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

public string getGetterMethodName ( )

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

            
getGetterReturnType() public method

Defined in: Yiisoft\Yii\Gii\Generator\ActiveRecord\AbstractRelation::getGetterReturnType()

Returns the return type for the getter method.

public string getGetterReturnType ( )

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

            
getInverseOf() public method

public string getInverseOf ( )

                public function getInverseOf(): string
{
    return lcfirst((new Inflector())->tableToClass($this->foreignKey->foreignTableName));
}

            
getLink() public method

public array getLink ( )

getName() public method
public string getName ( )

                public function getName(): string
{
    return lcfirst($this->getRelatedModel());
}

            
getQueryMethodName() public method

Defined in: Yiisoft\Yii\Gii\Generator\ActiveRecord\AbstractRelation::getQueryMethodName()

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

public string getQueryMethodName ( )

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

            
getRelatedModel() public method

public string getRelatedModel ( )

                public function getRelatedModel(): string
{
    return (new Inflector())->tableToClass($this->relatedTableName);
}

            
isHasMany() public method

Defined in: Yiisoft\Yii\Gii\Generator\ActiveRecord\AbstractRelation::isHasMany()

Returns true if this is a hasMany relation.

public boolean isHasMany ( )

                public function isHasMany(): bool
{
    return false;
}

            
isHasOne() public method

Defined in: Yiisoft\Yii\Gii\Generator\ActiveRecord\AbstractRelation::isHasOne()

Returns true if this is a hasOne relation.

public boolean isHasOne ( )

                public function isHasOne(): bool
{
    return true;
}