trait Illuminate / Database / Eloquent / Relations / Concerns / InteractsWithPivotTable

InteractsWithPivotTable

Methods

public

toggle ( $ids , $touch ) : array

Toggles a model (or models) from the parent.

Parameters

  • $ids mixed
  • $touch bool
public

syncWithoutDetaching ( $ids ) : array

Sync the intermediate tables with a list of IDs without detaching.

Parameters

  • $ids Illuminate\...\Collection|Model |array
public

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
public

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
protected

formatRecordsList ( array $records ) : array

Format the sync / toggle record list so that it is keyed by ID.

Parameters

  • $records array
protected

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
public

updateExistingPivot ( $id , array $attributes , $touch ) : int

Update an existing pivot record on the table.

Parameters

  • $id mixed
  • $attributes array
  • $touch bool
protected

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
public

attach ( $id , array $attributes , $touch ) : void

Attach a model to the parent.

Parameters

  • $id mixed
  • $attributes array
  • $touch bool
protected

attachUsingCustomClass ( $id , array $attributes ) : void

Attach a model to the parent using a custom class.

Parameters

  • $id mixed
  • $attributes array
protected

formatAttachRecords ( $ids , array $attributes ) : array

Create an array of records to insert into the pivot table.

Parameters

  • $ids array
  • $attributes array
protected

formatAttachRecord ( $key , $value , $attributes , $hasTimestamps ) : array

Create a full attachment record payload.

Parameters

  • $key int
  • $value mixed
  • $attributes array
  • $hasTimestamps bool
protected

extractAttachIdAndAttributes ( $key , $value , array $attributes ) : array

Get the attach record ID and extra attributes.

Parameters

  • $key mixed
  • $value mixed
  • $attributes array
protected

baseAttachRecord ( $id , $timed ) : array

Create a new pivot attachment record.

Parameters

  • $id int
  • $timed bool
protected

addTimestampsToAttachment ( array $record , $exists ) : array

Set the creation and update timestamps on an attach record.

Parameters

  • $record array
  • $exists bool
public

hasPivotColumn ( $column ) : bool

Determine whether the given column is defined as a pivot column.

Parameters

  • $column string
public

detach ( $ids , $touch ) : int

Detach models from the relationship.

Parameters

  • $ids mixed
  • $touch bool
protected

detachUsingCustomClass ( $ids ) : int

Detach models from the relationship using a custom class.

Parameters

  • $ids mixed
protected

getCurrentlyAttachedPivots ( ) : Illuminate\...\Collection

Get the pivot models that are currently attached.

public

newPivot ( array $attributes , $exists ) : Pivot

Create a new pivot model instance.

Parameters

  • $attributes array
  • $exists bool
public

newExistingPivot ( array $attributes ) : Pivot

Create a new existing pivot model instance.

Parameters

  • $attributes array
public

newPivotStatement ( ) : Builder

Get a new plain query builder for the pivot table.

public

newPivotStatementForId ( $id ) : Builder

Get a new pivot statement for a given "other" ID.

Parameters

  • $id mixed
public

newPivotQuery ( ) : Builder

Create a new query builder for the pivot table.

public

withPivot ( $columns ) : $this

Set the columns on the pivot table to retrieve.

Parameters

  • $columns array|mixed
protected

parseIds ( $value ) : array

Get all of the IDs from the given mixed value.

Parameters

  • $value mixed
protected

parseId ( $value ) : mixed

Get the ID from the given mixed value.

Parameters

  • $value mixed
protected

castKeys ( array $keys ) : array

Cast the given keys to integers if they are numeric and string otherwise.

Parameters

  • $keys array
protected

castKey ( $key ) : mixed

Cast the given key to convert to primary key type.

Parameters

  • $key mixed
protected

castAttributes ( $attributes ) : array

Cast the given pivot attributes.

Parameters

  • $attributes array
protected

getTypeSwapValue ( $type , $value ) : mixed

Converts a given value to a given type value.

Parameters

  • $type string
  • $value mixed