InteractsWithPivotTable
Methods
toggle ( $ids , $touch ) : array
Toggles a model (or models) from the parent.
Parameters
- $ids mixed
- $touch bool
syncWithoutDetaching ( $ids ) : array
Sync the intermediate tables with a list of IDs without detaching.
Parameters
- $ids Illuminate\...\Collection|Model |array
sync ( $ids , $detaching ) : array
Sync the intermediate tables with a list of IDs or collection of models.
Parameters
- $ids Illuminate\...\Collection|Model |array
- $detaching bool
syncWithPivotValues ( $ids , array $values , bool $detaching ) : array
Sync the intermediate tables with a list of IDs or collection of models with the given pivot values.
Parameters
- $ids Illuminate\...\Collection|Model |array
- $values array
- $detaching bool
formatRecordsList ( array $records ) : array
Format the sync / toggle record list so that it is keyed by ID.
Parameters
- $records array
attachNew ( array $records , array $current , $touch ) : array
Attach all of the records that aren't in the given current records.
Parameters
- $records array
- $current array
- $touch bool
updateExistingPivot ( $id , array $attributes , $touch ) : int
Update an existing pivot record on the table.
Parameters
- $id mixed
- $attributes array
- $touch bool
updateExistingPivotUsingCustomClass ( $id , array $attributes , $touch ) : int
Update an existing pivot record on the table via a custom class.
Parameters
- $id mixed
- $attributes array
- $touch bool
attach ( $id , array $attributes , $touch ) : void
Attach a model to the parent.
Parameters
- $id mixed
- $attributes array
- $touch bool
attachUsingCustomClass ( $id , array $attributes ) : void
Attach a model to the parent using a custom class.
Parameters
- $id mixed
- $attributes array
formatAttachRecords ( $ids , array $attributes ) : array
Create an array of records to insert into the pivot table.
Parameters
- $ids array
- $attributes array
formatAttachRecord ( $key , $value , $attributes , $hasTimestamps ) : array
Create a full attachment record payload.
Parameters
- $key int
- $value mixed
- $attributes array
- $hasTimestamps bool
extractAttachIdAndAttributes ( $key , $value , array $attributes ) : array
Get the attach record ID and extra attributes.
Parameters
- $key mixed
- $value mixed
- $attributes array
baseAttachRecord ( $id , $timed ) : array
Create a new pivot attachment record.
Parameters
- $id int
- $timed bool
addTimestampsToAttachment ( array $record , $exists ) : array
Set the creation and update timestamps on an attach record.
Parameters
- $record array
- $exists bool
hasPivotColumn ( $column ) : bool
Determine whether the given column is defined as a pivot column.
Parameters
- $column string
detach ( $ids , $touch ) : int
Detach models from the relationship.
Parameters
- $ids mixed
- $touch bool
detachUsingCustomClass ( $ids ) : int
Detach models from the relationship using a custom class.
Parameters
- $ids mixed
getCurrentlyAttachedPivots ( ) : Illuminate\...\Collection
Get the pivot models that are currently attached.
newPivot ( array $attributes , $exists ) : Pivot
Create a new pivot model instance.
Parameters
- $attributes array
- $exists bool
newExistingPivot ( array $attributes ) : Pivot
Create a new existing pivot model instance.
Parameters
- $attributes array
newPivotStatementForId ( $id ) : Builder
Get a new pivot statement for a given "other" ID.
Parameters
- $id mixed
withPivot ( $columns ) : $this
Set the columns on the pivot table to retrieve.
Parameters
- $columns array|mixed
parseIds ( $value ) : array
Get all of the IDs from the given mixed value.
Parameters
- $value mixed
parseId ( $value ) : mixed
Get the ID from the given mixed value.
Parameters
- $value mixed
castKeys ( array $keys ) : array
Cast the given keys to integers if they are numeric and string otherwise.
Parameters
- $keys array
castKey ( $key ) : mixed
Cast the given key to convert to primary key type.
Parameters
- $key mixed
castAttributes ( $attributes ) : array
Cast the given pivot attributes.
Parameters
- $attributes array
getTypeSwapValue ( $type , $value ) : mixed
Converts a given value to a given type value.
Parameters
- $type string
- $value mixed