PHP Class LMongo\Eloquent\Relations\HasOneOrMany

Inheritance: extends Relation
Afficher le fichier Open project: navruzm/lmongo Class Usage Examples

Protected Properties

Свойство Type Description
$foreignKey string The foreign key of the parent model.

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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
Résultat void

addConstraints() public méthode

Set the base constraints on the relation query.
public addConstraints ( ) : void
Résultat void

addEagerConstraints() public méthode

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

buildDictionary() protected méthode

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

create() public méthode

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

createMany() public méthode

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

getForeignKey() public méthode

Get the foreign key for the relationship.
public getForeignKey ( ) : string
Résultat string

getRelationValue() protected méthode

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 méthode

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
Résultat array

matchOne() public méthode

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
Résultat array

matchOneOrMany() protected méthode

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
Résultat array

save() public méthode

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

saveMany() public méthode

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

update() public méthode

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

Property Details

$foreignKey protected_oe property

The foreign key of the parent model.
protected string $foreignKey
Résultat string