PHP Class LMongo\Eloquent\Relations\HasOneOrMany

Inheritance: extends Relation
Exibir arquivo Open project: navruzm/lmongo Class Usage Examples

Protected Properties

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

Public Methods

Method Description
__construct ( Builder $query, Model $parent, string $foreignKey ) : 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.
create ( array $attributes ) : Model Create a new instance of the related model.
createMany ( array $records ) : array Create an array of new instances of the related model.
getForeignKey ( ) : string Get the foreign key for the relationship.
matchMany ( array $models, Collection $results, string $relation ) : array Match the eagerly loaded results to their many parents.
matchOne ( array $models, Collection $results, string $relation ) : array Match the eagerly loaded results to their single parents.
save ( Model $model ) : Model Attach a model instance to the parent model.
saveMany ( array $models ) : array Attach an array of models to the parent instance.
update ( array $attributes ) : integer Perform an update on all the related models.

Protected Methods

Method Description
buildDictionary ( Collection $results ) : array Build model dictionary keyed by the relation's foreign key.
getRelationValue ( array $dictionary, string $key, string $type ) Get the value of a relationship by one or many type.
matchOneOrMany ( array $models, Collection $results, string $relation, string $type ) : array Match the eagerly loaded results to their many parents.

Method Details

__construct() public method

Create a new has many relationship instance.
public __construct ( Builder $query, Model $parent, string $foreignKey ) : void
$query LMongo\Eloquent\Builder
$parent LMongo\Eloquent\Model
$foreignKey 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

buildDictionary() protected method

Build model dictionary keyed by the relation's foreign key.
protected buildDictionary ( Collection $results ) : array
$results LMongo\Eloquent\Collection
return array

create() public method

Create a new instance of the related model.
public create ( array $attributes ) : Model
$attributes array
return LMongo\Eloquent\Model

createMany() public method

Create an array of new instances of the related model.
public createMany ( array $records ) : array
$records array
return array

getForeignKey() public method

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

getRelationValue() protected method

Get the value of a relationship by one or many type.
protected getRelationValue ( array $dictionary, string $key, string $type )
$dictionary array
$key string
$type string

matchMany() public method

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

matchOne() public method

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

matchOneOrMany() protected method

Match the eagerly loaded results to their many parents.
protected matchOneOrMany ( array $models, Collection $results, string $relation, string $type ) : array
$models array
$results LMongo\Eloquent\Collection
$relation string
$type string
return array

save() public method

Attach a model instance to the parent model.
public save ( Model $model ) : Model
$model LMongo\Eloquent\Model
return LMongo\Eloquent\Model

saveMany() public method

Attach an array of models to the parent instance.
public saveMany ( array $models ) : array
$models array
return array

update() public method

Perform an update on all the related models.
public update ( array $attributes ) : integer
$attributes array
return integer

Property Details

$foreignKey protected_oe property

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