class HasOne extends HasOne

Adapted from october\rain\database\relations\HasOne

Traits

Adapted from october\rain\database\relations\HasOneOrMany

Adapted from october\rain\database\relations\DeferOneOrMany

Properties

protected string $relationName from  HasOneOrMany

Methods

Builder
withDeferred($sessionKey)

Returns the model query with deferred bindings added

Expression
getWithDeferredQualifiedKeyName()

Returns the related "slave id" key in a database friendly format.

save(Model $model, $sessionKey = null)

Save the supplied related model with deferred binding support.

array
saveMany(array $models, $sessionKey = null)

Alias for the addMany() method.

create(array $attributes = [], $sessionKey = null)

Create a new instance of this related model with deferred binding support.

add(Model $model, $sessionKey = null)

Adds a model to this relationship type.

void
addMany(array $models, $sessionKey = null)

Attach an array of models to the parent instance with deferred binding support.

remove(Model $model, $sessionKey = null)

Removes a model from this relationship type.

string
getForeignKey()

Get the foreign key for the relationship.

string
getOtherKey()

Get the associated "other" key of the relationship.

void
addDefinedConstraints()

Set the defined constraints on the relation query.

addDefinedConstraintsToRelation(Relation $relation, array $args = null)

Add relation based constraints.

addDefinedConstraintsToQuery(Builder $query, array $args = null)

Add query based constraints.

void
__construct(Builder $query, Model $parent, $foreignKey, $localKey, $relationName = null)

Create a new has many relationship instance.

mixed
getResults()

Get the results of the relationship.

setSimpleValue($value)

Helper for setting this relationship using various expected values. For example, $model->relation = $value;

getSimpleValue()

Helper for getting this relationship simple value, generally useful with form values.

Details

in DeferOneOrMany at line 17
Builder withDeferred($sessionKey)

Returns the model query with deferred bindings added

Parameters

$sessionKey

Return Value

Builder

in DeferOneOrMany at line 125
protected Expression getWithDeferredQualifiedKeyName()

Returns the related "slave id" key in a database friendly format.

Return Value

Expression

in HasOneOrMany at line 22
save(Model $model, $sessionKey = null)

Save the supplied related model with deferred binding support.

Parameters

Model $model
$sessionKey

in HasOneOrMany at line 38
array saveMany(array $models, $sessionKey = null)

Alias for the addMany() method.

Parameters

array $models
$sessionKey

Return Value

array

in HasOneOrMany at line 48
create(array $attributes = [], $sessionKey = null)

Create a new instance of this related model with deferred binding support.

Parameters

array $attributes
$sessionKey

in HasOneOrMany at line 62
add(Model $model, $sessionKey = null)

Adds a model to this relationship type.

Parameters

Model $model
$sessionKey

in HasOneOrMany at line 91
void addMany(array $models, $sessionKey = null)

Attach an array of models to the parent instance with deferred binding support.

Parameters

array $models
$sessionKey

Return Value

void

in HasOneOrMany at line 101
remove(Model $model, $sessionKey = null)

Removes a model from this relationship type.

Parameters

Model $model
$sessionKey

in HasOneOrMany at line 126
string getForeignKey()

Get the foreign key for the relationship.

Return Value

string

in HasOneOrMany at line 135
string getOtherKey()

Get the associated "other" key of the relationship.

Return Value

string

in DefinedConstraints at line 20
void addDefinedConstraints()

Set the defined constraints on the relation query.

Return Value

void

in DefinedConstraints at line 35
addDefinedConstraintsToRelation(Relation $relation, array $args = null)

Add relation based constraints.

Parameters

Relation $relation
array $args

in DefinedConstraints at line 85
addDefinedConstraintsToQuery(Builder $query, array $args = null)

Add query based constraints.

Parameters

Builder $query
array $args

at line 21
void __construct(Builder $query, Model $parent, $foreignKey, $localKey, $relationName = null)

Create a new has many relationship instance.

Parameters

Builder $query
Model $parent
$foreignKey
$localKey
$relationName

Return Value

void

at line 34
mixed getResults()

Get the results of the relationship.

Return Value

mixed

at line 49
setSimpleValue($value)

Helper for setting this relationship using various expected values. For example, $model->relation = $value;

Parameters

$value

at line 99
getSimpleValue()

Helper for getting this relationship simple value, generally useful with form values.