PolymorphicRelations
Polymorphic Relations (Many To Many) trait
Table of Contents
Methods
- deleteRelation() : bool
- Delete relation
- deleteRelations() : bool
- Delete relations
- getItemsQuery() : Builder
- Get relations
- getRelatedItems() : Collection|null
- Get relations items
- getRelationAttributeName() : string|null
- Get relation attribute name
- getRelationModel() : Model|false
- Get relation
- getRelationModelClass() : string|null
- Get relation model class
- getRelationsQuery() : Builder
- Get relations query for model id
- hasRelatedItems() : bool
- Return true if related items > 0
- hasRelation() : bool
- Return true if relation exist
- related() : mixed
- Morphed model
- relations() : Relation
- Relations
- saveRelation() : Model|false
- Save relation
- saveRelations() : array<string|int, mixed>
- Save relations
Methods
deleteRelation()
Delete relation
public
deleteRelation([int|string|null $id = null ]) : bool
Parameters
- $id : int|string|null = null
Return values
booldeleteRelations()
Delete relations
public
deleteRelations(int|null $id[, string|null $type = null ][, int|null $relationId = null ]) : bool
Parameters
- $id : int|null
- $type : string|null = null
- $relationId : int|null = null
Return values
boolgetItemsQuery()
Get relations
public
getItemsQuery(int|null $id[, string|null $type = null ]) : Builder
Parameters
- $id : int|null
- $type : string|null = null
Return values
BuildergetRelatedItems()
Get relations items
public
getRelatedItems(int|null $relationId[, string|null $type = null ]) : Collection|null
Parameters
- $relationId : int|null
- $type : string|null = null
Return values
Collection|nullgetRelationAttributeName()
Get relation attribute name
public
getRelationAttributeName() : string|null
Return values
string|nullgetRelationModel()
Get relation
public
getRelationModel(int|null $id, string|null $type, int|null $relationId) : Model|false
Parameters
- $id : int|null
- $type : string|null
- $relationId : int|null
Return values
Model|falsegetRelationModelClass()
Get relation model class
public
getRelationModelClass() : string|null
Return values
string|nullgetRelationsQuery()
Get relations query for model id
public
getRelationsQuery(int|null $relationId[, string|null $type = null ]) : Builder
Parameters
- $relationId : int|null
- $type : string|null = null
Return values
BuilderhasRelatedItems()
Return true if related items > 0
public
hasRelatedItems(int|null $id[, string|null $type = null ]) : bool
Parameters
- $id : int|null
- $type : string|null = null
Return values
boolhasRelation()
Return true if relation exist
public
hasRelation(int|null $id, string|null $type, int|null $relationId) : bool
Parameters
- $id : int|null
- $type : string|null
- $relationId : int|null
Return values
boolrelated()
Morphed model
public
related([string|null $type = null ]) : mixed
Parameters
- $type : string|null = null
relations()
Relations
public
relations() : Relation
Return values
RelationsaveRelation()
Save relation
public
saveRelation(int|null $id, string|null $type, int|null $relationId) : Model|false
Parameters
- $id : int|null
- $type : string|null
- $relationId : int|null
Return values
Model|falsesaveRelations()
Save relations
public
saveRelations(array<string|int, mixed> $items, string|null $type, int|null $relationId) : array<string|int, mixed>
Parameters
- $items : array<string|int, mixed>
- $type : string|null
- $relationId : int|null