PHP Class LMongo\Eloquent\Relations\BelongsTo

Inheritance: extends Relation
Datei anzeigen Open project: navruzm/lmongo

Protected Properties

Property Type Description
$foreignKey string The foreign key of the parent model.
$relation string The name of the relationship.

Public Methods

Method Description
__construct ( Builder $query, Model $parent, string $foreignKey, string $relation ) : void Create a new has many relationship instance.
addConstraints ( ) : void Set the base constraints on the relation query.
addEagerConstraints ( array $models ) : void Set the constraints for an eager load of the relation.
associate ( Model $model ) : Model Associate the model instance to the given parent.
getForeignKey ( ) : string Get the foreign key of the relationship.
getResults ( ) : mixed Get the results of the relationship.
initRelation ( array $models, string $relation ) : void Initialize the relation on a set of models.
match ( array $models, Collection $results, string $relation ) : array Match the eagerly loaded results to their parents.
update ( array $attributes ) : mixed Update the parent model on the relationship.

Protected Methods

Method Description
getEagerModelKeys ( array $models ) : array Gather the keys from an array of related models.

Method Details

__construct() public method

Create a new has many relationship instance.
public __construct ( Builder $query, Model $parent, string $foreignKey, string $relation ) : void
$query LMongo\Eloquent\Builder
$parent LMongo\Eloquent\Model
$foreignKey string
$relation string
return void

addConstraints() public method

Set the base constraints on the relation query.
public addConstraints ( ) : void
return void

addEagerConstraints() public method

Set the constraints for an eager load of the relation.
public addEagerConstraints ( array $models ) : void
$models array
return void

associate() public method

Associate the model instance to the given parent.
public associate ( Model $model ) : Model
$model LMongo\Eloquent\Model
return LMongo\Eloquent\Model

getEagerModelKeys() protected method

Gather the keys from an array of related models.
protected getEagerModelKeys ( array $models ) : array
$models array
return array

getForeignKey() public method

Get the foreign key of the relationship.
public getForeignKey ( ) : string
return string

getResults() public method

Get the results of the relationship.
public getResults ( ) : mixed
return mixed

initRelation() public method

Initialize the relation on a set of models.
public initRelation ( array $models, string $relation ) : void
$models array
$relation string
return void

match() public method

Match the eagerly loaded results to their parents.
public match ( array $models, Collection $results, string $relation ) : array
$models array
$results LMongo\Eloquent\Collection
$relation string
return array

update() public method

Update the parent model on the relationship.
public update ( array $attributes ) : mixed
$attributes array
return mixed

Property Details

$foreignKey protected_oe property

The foreign key of the parent model.
protected string $foreignKey
return string

$relation protected_oe property

The name of the relationship.
protected string $relation
return string