PHP Class LMongo\Eloquent\Relations\BelongsToMany

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

Protected Properties

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

Public Methods

Method Description
__construct ( Builder $query, Model $parent, string $foreignKey, string $otherKey ) : void Create a new has many relationship instance.
attach ( mixed $related ) : void Attach a model to the parent.
create ( array $attributes ) : Model Create a new instance of the related model.
createMany ( array $records ) : Model Create an array of new instances of the related models.
detach ( integer $related ) : void Detach models from the relationship.
getOtherKey ( ) : string Get the other key for 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.
save ( Model $model ) : Model Save a new model and attach it to the parent model.
saveMany ( array $models ) : array Save an array of new models and attach them to the parent model.
sync ( array $ids ) : void Sync the intermediate tables with a list of IDs.

Protected Methods

Method Description
buildDictionary ( Collection $results ) : array Build model dictionary keyed by the relation's foreign key.

Method Details

__construct() public method

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

attach() public method

Attach a model to the parent.
public attach ( mixed $related ) : void
$related mixed
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 models.
public createMany ( array $records ) : Model
$records array
return LMongo\Eloquent\Model

detach() public method

Detach models from the relationship.
public detach ( integer $related ) : void
$related integer
return void

getOtherKey() public method

Get the other key for the relationship.
public getOtherKey ( ) : 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

save() public method

Save a new model and attach it to the parent model.
public save ( Model $model ) : Model
$model LMongo\Eloquent\Model
return LMongo\Eloquent\Model

saveMany() public method

Save an array of new models and attach them to the parent model.
public saveMany ( array $models ) : array
$models array
return array

sync() public method

Sync the intermediate tables with a list of IDs.
public sync ( array $ids ) : void
$ids array
return void

Property Details

$foreignKey protected_oe property

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

$otherKey protected_oe property

The associated key of the relation.
protected string $otherKey
return string