Contents

October\Rain\Database\Relations\DefinedConstraints

Overview

DefinedConstraints handles the constraints and filters defined by a relation eg: 'conditions' => 'is_published = 1'


Protected Properties

protected bool $pivotSiteScope

pivotSiteScope indicates if pivot queries should be scoped by site_id. This is used for dual-multisite scenarios where both parent and related models use multisite.


Public Methods

public addDefinedConstraints()

public addDefinedConstraints(): void 

addDefinedConstraints to the relation query

public addDefinedConstraintsToQuery()

public addDefinedConstraintsToQuery($query, $args = null): void

public addDefinedConstraintsToRelation()

public addDefinedConstraintsToRelation($relation, $args = null): void

public isPivotSiteScoped()

public isPivotSiteScoped(): bool 

isPivotSiteScoped returns true if pivot queries should be scoped by site_id.

Protected Methods

protected addPivotSiteScopeConstraints()

protected addPivotSiteScopeConstraints(): void 

addPivotSiteScopeConstraints adds site_id constraint to pivot queries if enabled.

protected getPivotSiteScopeValue()

protected getPivotSiteScopeValue(): int|null 

getPivotSiteScopeValue returns the current site_id value for pivot records. Returns null if pivotSiteScope is disabled, otherwise returns the site ID.

protected getRelationDefinitionForDefinedConstraints()

protected getRelationDefinitionForDefinedConstraints(): void

getRelationDefinitionForDefinedConstraints returns the relation definition for the relationship context.