October\Rain\Database\Relations\HasOne

Source: ~/vendor/october/rain/src/Database/Relations/HasOne.php

Extends:

  • Illuminate\Database\Eloquent\Relations\HasOne
  • Illuminate\Database\Eloquent\Relations\HasOneOrMany
  • Illuminate\Database\Eloquent\Relations\Relation

Public properties

There are no public properties in the class.

Show inherited public properties

Inherited public properties

  • public static array $morphMap - defined in Illuminate\Database\Eloquent\Relations\Relation. An array to map class names to their morph names in database.

Protected properties

protected string $relationName

The "name" of the relationship.

Show inherited protected properties

Inherited protected properties

  • protected string $foreignKey - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. The foreign key of the parent model.
  • protected string $localKey - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. The local key of the parent model.
  • protected static int $selfJoinCount - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. The count of self joins.
  • protected Illuminate\Database\Eloquent\Builder $query - defined in Illuminate\Database\Eloquent\Relations\Relation. The Eloquent query builder instance.
  • protected Illuminate\Database\Eloquent\Model $parent - defined in Illuminate\Database\Eloquent\Relations\Relation. The parent model instance.
  • protected Illuminate\Database\Eloquent\Model $related - defined in Illuminate\Database\Eloquent\Relations\Relation. The related model instance.
  • protected static bool $constraints - defined in Illuminate\Database\Eloquent\Relations\Relation. Indicates if the relation is adding constraints.
  • protected static array $macros - defined in Illuminate\Database\Eloquent\Relations\Relation. The registered string macros.
  • protected Closure|array|bool $withDefault - defined in Illuminate\Database\Eloquent\Relations\HasOne. Indicates if a default model instance should be used.

Public methods

public void __construct($query, $parent, $foreignKey, $localKey, $relationName=NULL)

Create a new has many relationship instance.

Parameters
  • $query
  • $parent
  • $foreignKey
  • $localKey
  • $relationName

public void add($model, $sessionKey=NULL)

Adds a model to this relationship type.

Parameters
  • $model
  • $sessionKey

public void addDefinedConstraints()

Set the defined constraints on the relation query.

public void addDefinedConstraintsToQuery(October\Rain\Database\QueryBuilder $query, array $args=NULL)

Add query based constraints.

Parameters

public void addDefinedConstraintsToRelation(Illuminate\Database\Eloquent\Relations\Relation $relation, array $args=NULL)

Add relation based constraints.

Parameters
  • Illuminate\Database\Eloquent\Relations\Relation $relation
  • array $args

public void addMany(array $models, $sessionKey=NULL)

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

Parameters
  • array $models
  • $sessionKey

public void create($attributes=array(), $sessionKey=NULL)

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

Parameters
  • $attributes
  • $sessionKey

public string getForeignKey()

Get the foreign key for the relationship.

public string getOtherKey()

Get the associated "other" key of the relationship.

public mixed getResults()

Get the results of the relationship.

public void getSimpleValue()

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

public void remove($model, $sessionKey=NULL)

Removes a model from this relationship type.

Parameters
  • $model
  • $sessionKey

public void save($model, $sessionKey=NULL)

Save the supplied related model with deferred binding support.

Parameters
  • $model
  • $sessionKey

public array saveMany(array $models, $sessionKey=NULL)

Alias for the addMany() method.

Parameters
  • array $models
  • $sessionKey

public void setSimpleValue($value)

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

Parameters
  • $value

public Illuminate\Database\Query\Builder withDeferred($sessionKey)

Returns the model query with deferred bindings added

Parameters
  • $sessionKey

Show inherited public methods

Inherited public methods

  • public mixed __call(string $method, array $parameters) - defined in Illuminate\Database\Eloquent\Relations\Relation. Handle dynamic method calls to the relationship.
  • public static mixed __callStatic(string $method, array $parameters) - defined in Illuminate\Database\Eloquent\Relations\Relation. Dynamically handle calls to the class.
  • public void __clone() - defined in Illuminate\Database\Eloquent\Relations\Relation. Force a clone of the underlying query builder when cloning.
  • public void addConstraints() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Set the base constraints on the relation query.
  • public void addEagerConstraints(array $models) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Set the constraints for an eager load of the relation.
  • public Illuminate\Database\Eloquent\Collection createMany(array $records) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Create a Collection of new instances of the related model.
  • public string createdAt() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the name of the "created at" column.
  • public Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model findOrNew(mixed $id, array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Find a model by its primary key or return new instance of the related model.
  • public Illuminate\Database\Eloquent\Model firstOrCreate(array $attributes, array $values=array()) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the first related record matching the attributes or create it.
  • public Illuminate\Database\Eloquent\Model firstOrNew(array $attributes, array $values=array()) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the first related model record matching the attributes or instantiate it.
  • public Illuminate\Database\Eloquent\Collection get(array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\Relation. Execute the query as a "select" statement.
  • public Illuminate\Database\Query\Builder getBaseQuery() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the base query builder driving the Eloquent builder.
  • public Illuminate\Database\Eloquent\Collection getEager() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the relationship for eager loading.
  • public string getExistenceCompareKey() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the key for comparing against the parent key in "has" query.
  • public string getForeignKeyName() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the plain foreign key.
  • public static string|null getMorphedModel(string $alias) - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the model associated with a custom polymorphic type.
  • public Illuminate\Database\Eloquent\Model getParent() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the parent model of the relation.
  • public mixed getParentKey() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the key value of the parent's local key.
  • public string getQualifiedForeignKeyName() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the foreign key for the relationship.
  • public string getQualifiedParentKeyName() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the fully qualified parent key name.
  • public Illuminate\Database\Eloquent\Builder getQuery() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the underlying query for the relation.
  • public Illuminate\Database\Eloquent\Model getRelated() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the related model of the relation.
  • public string getRelationCountHash() - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get a relationship join table hash.
  • public Illuminate\Database\Eloquent\Builder getRelationExistenceCountQuery(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parentQuery) - defined in Illuminate\Database\Eloquent\Relations\Relation. Add the constraints for a relationship count query.
  • public Illuminate\Database\Eloquent\Builder getRelationExistenceQuery(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parentQuery, array|mixed $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Add the constraints for a relationship query.
  • public Illuminate\Database\Eloquent\Builder getRelationExistenceQueryForSelfRelation(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parentQuery, array|mixed $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Add the constraints for a relationship query on the same table.
  • public static bool hasMacro(string $name) - defined in Illuminate\Database\Eloquent\Relations\Relation. Checks if macro is registered.
  • public array initRelation(array $models, string $relation) - defined in Illuminate\Database\Eloquent\Relations\HasOne. Initialize the relation on a set of models.
  • public static void macro(string $name, object|callable $macro) - defined in Illuminate\Database\Eloquent\Relations\Relation. Register a custom macro.
  • public mixed macroCall(string $method, array $parameters) - defined in Illuminate\Database\Eloquent\Relations\Relation. Dynamically handle calls to the class.
  • public Illuminate\Database\Eloquent\Model make(array $attributes=array()) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Create and return an un-saved instance of the related model.
  • public array match(array $models, Illuminate\Database\Eloquent\Collection $results, string $relation) - defined in Illuminate\Database\Eloquent\Relations\HasOne. Match the eagerly loaded results to their parents.
  • public array matchMany(array $models, Illuminate\Database\Eloquent\Collection $results, string $relation) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Match the eagerly loaded results to their many parents.
  • public array matchOne(array $models, Illuminate\Database\Eloquent\Collection $results, string $relation) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Match the eagerly loaded results to their single parents.
  • public static void mixin(object $mixin) - defined in Illuminate\Database\Eloquent\Relations\Relation. Mix another object into the class.
  • public static array morphMap(array|null $map=NULL, bool $merge=true) - defined in Illuminate\Database\Eloquent\Relations\Relation. Set or get the morph map for polymorphic relations.
  • public Illuminate\Database\Eloquent\Model newRelatedInstanceFor(Illuminate\Database\Eloquent\Model $parent) - defined in Illuminate\Database\Eloquent\Relations\HasOne. Make a new related instance for the given model.
  • public static mixed noConstraints(Closure $callback) - defined in Illuminate\Database\Eloquent\Relations\Relation. Run a callback with constraints disabled on the relation.
  • public int rawUpdate(array $attributes=array()) - defined in Illuminate\Database\Eloquent\Relations\Relation. Run a raw update against the base query.
  • public string relatedUpdatedAt() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the name of the related model's "updated at" column.
  • public void touch() - defined in Illuminate\Database\Eloquent\Relations\Relation. Touch all of the related models for the relationship.
  • public int update(array $attributes) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Perform an update on all the related models.
  • public Illuminate\Database\Eloquent\Model updateOrCreate(array $attributes, array $values=array()) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Create or update a related record matching the attributes, and fill it with values.
  • public string updatedAt() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the name of the "updated at" column.
  • public $this withDefault(Closure|array|bool $callback=true) - defined in Illuminate\Database\Eloquent\Relations\HasOne. Return a new model instance in case the relationship does not exist.

Protected methods

protected Illuminate\Database\Query\Expression getWithDeferredQualifiedKeyName()

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

Show inherited protected methods

Inherited protected methods

  • protected array buildDictionary(Illuminate\Database\Eloquent\Collection $results) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Build model dictionary keyed by the relation's foreign key.
  • protected static array|null buildMorphMapFromModels(array $models=NULL) - defined in Illuminate\Database\Eloquent\Relations\Relation. Builds a table-keyed array from model class names.
  • protected Illuminate\Database\Eloquent\Model|null getDefaultFor(Illuminate\Database\Eloquent\Model $parent) - defined in Illuminate\Database\Eloquent\Relations\HasOne. Get the default value for this relation.
  • protected array getKeys(array $models, string $key=NULL) - defined in Illuminate\Database\Eloquent\Relations\Relation. Get all of the primary keys for an array of models.
  • protected mixed getRelationValue(array $dictionary, string $key, string $type) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Get the value of a relationship by one or many type.
  • protected array matchOneOrMany(array $models, Illuminate\Database\Eloquent\Collection $results, string $relation, string $type) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Match the eagerly loaded results to their many parents.
  • protected void setForeignAttributesForCreate(Illuminate\Database\Eloquent\Model $model) - defined in Illuminate\Database\Eloquent\Relations\HasOneOrMany. Set the foreign ID for creating a related model.