trait InteractsWithPivotTable (View source)
array | toggle(mixed $ids, bool $touch = true) Toggles a model (or models) from the parent. | |
array | syncWithoutDetaching(Collection|array $ids) Sync the intermediate tables with a list of IDs without detaching. | |
array | sync(Collection|Collection|array $ids, bool $detaching = true) Sync the intermediate tables with a list of IDs or collection of models. | |
int | updateExistingPivot(mixed $id, array $attributes, bool $touch = true) Update an existing pivot record on the table. | |
void | attach(mixed $id, array $attributes = array(), bool $touch = true) Attach a model to the parent. | |
int | detach(mixed $ids = null, bool $touch = true) Detach models from the relationship. | |
Pivot | newPivot(array $attributes = array(), bool $exists = false) Create a new pivot model instance. | |
Pivot | newExistingPivot(array $attributes = array()) Create a new existing pivot model instance. | |
Builder | newPivotStatement() Get a new plain query builder for the pivot table. | |
Builder | newPivotStatementForId(mixed $id) Get a new pivot statement for a given "other" ID. | |
$this | withPivot(array|mixed $columns) Set the columns on the pivot table to retrieve. |
Toggles a model (or models) from the parent.
Each existing model is detached, and non existing ones are attached.
Sync the intermediate tables with a list of IDs without detaching.
Sync the intermediate tables with a list of IDs or collection of models.
Update an existing pivot record on the table.
Attach a model to the parent.
Detach models from the relationship.
Create a new pivot model instance.
Create a new existing pivot model instance.
Get a new plain query builder for the pivot table.
Get a new pivot statement for a given "other" ID.
Set the columns on the pivot table to retrieve.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.4/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.html