You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

HasOne

Extends

Implements

Uses

Methods

public

getResults ( ) : mixed

Get the results of the relationship.

public

initRelation ( array $models , $relation ) : array

Initialize the relation on a set of models.

Parameters

  • $models array
  • $relation string
public

match ( array $models , Illuminate\...\Collection $results , $relation ) : array

Match the eagerly loaded results to their parents.

Parameters

  • $models array
  • $results Illuminate\...\Collection
  • $relation string
public

getRelationExistenceQuery ( Builder $query , Builder $parentQuery , $columns ) : Builder

Add the constraints for an internal relationship existence query.

Parameters

public

addOneOfManySubQueryConstraints ( Builder $query , $column , $aggregate ) : void

Add constraints for inner join subselect for one of many relationships.

Parameters

  • $query Builder
  • $column string|null
  • $aggregate string|null
public

getOneOfManySubQuerySelectColumns ( ) : array|string

Get the columns that should be selected by the one of many subquery.

public

addOneOfManyJoinSubQueryConstraints ( JoinClause $join ) : void

Add join query constraints for one of many relationships.

Parameters

public

newRelatedInstanceFor ( Model $parent ) : Model

Make a new related instance for the given model.

Parameters

protected

getRelatedKeyFrom ( Model $model ) : mixed

Get the value of the model's foreign key.

Parameters