HasOne
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
Returns the model query with deferred bindings added
Returns the related "slave id" key in a database friendly format.
Save the supplied related model with deferred binding support.
Create a new instance of this related model with deferred binding support.
Attach an array of models to the parent instance with deferred binding support.
Removes a model from this relationship type.
Set the defined constraints on the relation query.
Add relation based constraints.
Create a new has many relationship instance.
Get the results of the relationship.
Helper for setting this relationship using various expected values. For example, $model->relation = $value;
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
in
DeferOneOrMany at line 125
protected Expression
getWithDeferredQualifiedKeyName()
Returns the related "slave id" key in a database friendly format.
in
HasOneOrMany at line 22
save(Model $model, $sessionKey = null)
Save the supplied related model with deferred binding support.
in
HasOneOrMany at line 38
array
saveMany(array $models, $sessionKey = null)
Alias for the addMany() method.
in
HasOneOrMany at line 48
create(array $attributes = [], $sessionKey = null)
Create a new instance of this related model with deferred binding support.
in
HasOneOrMany at line 62
add(Model $model, $sessionKey = null)
Adds a model to this relationship type.
in
HasOneOrMany at line 91
void
addMany(array $models, $sessionKey = null)
Attach an array of models to the parent instance with deferred binding support.
in
HasOneOrMany at line 101
remove(Model $model, $sessionKey = null)
Removes a model from this relationship type.
in
HasOneOrMany at line 126
string
getForeignKey()
Get the foreign key for the relationship.
in
HasOneOrMany at line 135
string
getOtherKey()
Get the associated "other" key of the relationship.
in
DefinedConstraints at line 20
void
addDefinedConstraints()
Set the defined constraints on the relation query.
in
DefinedConstraints at line 35
addDefinedConstraintsToRelation(Relation $relation, array $args = null)
Add relation based constraints.
in
DefinedConstraints at line 85
addDefinedConstraintsToQuery(Builder $query, array $args = null)
Add query based constraints.
at line 21
void
__construct(Builder $query, Model $parent, $foreignKey, $localKey, $relationName = null)
Create a new has many relationship instance.
at line 34
mixed
getResults()
Get the results of the relationship.
at line 49
setSimpleValue($value)
Helper for setting this relationship using various expected values. For example, $model->relation = $value;
at line 99
getSimpleValue()
Helper for getting this relationship simple value, generally useful with form values.