AsPivot
trait AsPivot
Properties
| Model|null | $pivotParent | The parent model of the relationship. |
|
| Model|null | $pivotRelated | The related model of the relationship. |
|
| protected string | $foreignKey | The name of the foreign key column. |
|
| protected string | $relatedKey | The name of the "other key" column. |
|
| protected null|list<array{string, array<int, mixed>}> | $pivotConstraints | The relation-owned predicates that identify this pivot row. |
Methods
Create a new pivot model instance.
Create a new pivot model from raw values returned from a query.
Delete the pivot model record from the database.
Get the query builder for a delete operation on the pivot.
Apply the relation-owned predicates to a pivot identity query.
Get a pivot key for a query.
Get the table associated with the model.
Get the foreign key column name.
Get the "related key" column name.
Get the "related key" column name.
Set the key names for the pivot model instance.
Set the relation-owned predicates for the pivot model.
Determine if the pivot model or given attributes has timestamp attributes.
Get the name of the "created at" column.
Get the name of the "updated at" column.
Get the queueable identity for the entity.
Get a new query to restore one or more models by their queueable IDs.
Get a new query to restore multiple models by their queueable IDs.
Unset all the loaded relations for the instance.
Details
at line 44
static AsPivot
fromAttributes(Model $parent, array $attributes, string $table, bool $exists = false)
Create a new pivot model instance.
at line 71
static AsPivot
fromRawAttributes(Model $parent, array $attributes, string $table, bool $exists = false)
Create a new pivot model from raw values returned from a query.
at line 110
protected Builder
setKeysForSaveQuery(Builder $query)
Set the keys for a save update query.
at line 121
int
delete()
Delete the pivot model record from the database.
Returns affected row count (int) rather than bool|null because pivots use query builder deletion with compound keys.
at line 145
protected Builder
getDeleteQuery()
Get the query builder for a delete operation on the pivot.
at line 161
protected Builder
applyPivotConstraints(Builder $query)
Apply the relation-owned predicates to a pivot identity query.
at line 179
protected mixed
getPivotKeyForQuery(string $column)
Get a pivot key for a query.
at line 193
string
getTable()
Get the table associated with the model.
at line 209
string
getForeignKey()
Get the foreign key column name.
at line 217
string
getRelatedKey()
Get the "related key" column name.
at line 225
string
getOtherKey()
Get the "related key" column name.
at line 235
AsPivot
setPivotKeys(string $foreignKey, string $relatedKey)
Set the key names for the pivot model instance.
at line 250
AsPivot
setPivotConstraints(array $constraints)
Set the relation-owned predicates for the pivot model.
at line 262
AsPivot
setRelatedModel(Model|null $related = null)
Set the related model of the relationship.
at line 272
bool
hasTimestampAttributes(array|null $attributes = null)
Determine if the pivot model or given attributes has timestamp attributes.
at line 281
string|null
getCreatedAtColumn()
Get the name of the "created at" column.
at line 291
string|null
getUpdatedAtColumn()
Get the name of the "updated at" column.
at line 303
mixed
getQueueableId()
Get the queueable identity for the entity.
at line 323
Builder
newQueryForRestoration(array|int|string $ids)
Get a new query to restore one or more models by their queueable IDs.
at line 346
protected Builder
newQueryForCollectionRestoration(array $ids)
Get a new query to restore multiple models by their queueable IDs.
at line 373
AsPivot
unsetRelations()
Unset all the loaded relations for the instance.