trait AsPivot (View source)

Properties

Model $pivotParent

The parent model of the relationship.

Model $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.

Methods

static AsPivot
fromAttributes(Model $parent, array $attributes, string $table, bool $exists = false)

Create a new pivot model instance.

static AsPivot
fromRawAttributes(Model $parent, array $attributes, string $table, bool $exists = false)

Create a new pivot model from raw values returned from a query.

Builder<static>
setKeysForSelectQuery(Builder<static> $query)

Set the keys for a select query.

Builder<static>
setKeysForSaveQuery(Builder<static> $query)

Set the keys for a save update query.

int
delete()

Delete the pivot model record from the database.

Builder<static>
getDeleteQuery()

Get the query builder for a delete operation on the pivot.

string
getTable()

Get the table associated with the model.

string
getForeignKey()

Get the foreign key column name.

string
getRelatedKey()

Get the "related key" column name.

string
getOtherKey()

Get the "related key" column name.

$this
setPivotKeys(string $foreignKey, string $relatedKey)

Set the key names for the pivot model instance.

$this
setRelatedModel(Model|null $related = null)

Set the related model of the relationship.

bool
hasTimestampAttributes(array|null $attributes = null)

Determine if the pivot model or given attributes has timestamp attributes.

string
getCreatedAtColumn()

Get the name of the "created at" column.

string
getUpdatedAtColumn()

Get the name of the "updated at" column.

mixed
getQueueableId()

Get the queueable identity for the entity.

Builder<static>
newQueryForRestoration(int[]|string[]|string $ids)

Get a new query to restore one or more models by their queueable IDs.

Builder<static>
newQueryForCollectionRestoration(array $ids)

Get a new query to restore multiple models by their queueable IDs.

$this
unsetRelations()

Unset all the loaded relations for the instance.

Details

static AsPivot fromAttributes(Model $parent, array $attributes, string $table, bool $exists = false)

Create a new pivot model instance.

Parameters

Model $parent
array $attributes
string $table
bool $exists

Return Value

AsPivot

static AsPivot fromRawAttributes(Model $parent, array $attributes, string $table, bool $exists = false)

Create a new pivot model from raw values returned from a query.

Parameters

Model $parent
array $attributes
string $table
bool $exists

Return Value

AsPivot

protected Builder<static> setKeysForSelectQuery(Builder<static> $query)

Set the keys for a select query.

Parameters

Builder<static> $query

Return Value

Builder<static>

protected Builder<static> setKeysForSaveQuery(Builder<static> $query)

Set the keys for a save update query.

Parameters

Builder<static> $query

Return Value

Builder<static>

int delete()

Delete the pivot model record from the database.

Return Value

int

protected Builder<static> getDeleteQuery()

Get the query builder for a delete operation on the pivot.

Return Value

Builder<static>

string getTable()

Get the table associated with the model.

Return Value

string

string getForeignKey()

Get the foreign key column name.

Return Value

string

string getRelatedKey()

Get the "related key" column name.

Return Value

string

string getOtherKey()

Get the "related key" column name.

Return Value

string

$this setPivotKeys(string $foreignKey, string $relatedKey)

Set the key names for the pivot model instance.

Parameters

string $foreignKey
string $relatedKey

Return Value

$this

$this setRelatedModel(Model|null $related = null)

Set the related model of the relationship.

Parameters

Model|null $related

Return Value

$this

bool hasTimestampAttributes(array|null $attributes = null)

Determine if the pivot model or given attributes has timestamp attributes.

Parameters

array|null $attributes

Return Value

bool

string getCreatedAtColumn()

Get the name of the "created at" column.

Return Value

string

string getUpdatedAtColumn()

Get the name of the "updated at" column.

Return Value

string

mixed getQueueableId()

Get the queueable identity for the entity.

Return Value

mixed

Builder<static> newQueryForRestoration(int[]|string[]|string $ids)

Get a new query to restore one or more models by their queueable IDs.

Parameters

int[]|string[]|string $ids

Return Value

Builder<static>

protected Builder<static> newQueryForCollectionRestoration(array $ids)

Get a new query to restore multiple models by their queueable IDs.

Parameters

array $ids

Return Value

Builder<static>

$this unsetRelations()

Unset all the loaded relations for the instance.

Return Value

$this