class Illuminate / Database / Eloquent / Relations / MorphToMany
You are viewing an older version of the documentation. For the latest, please visit master documentation.

MorphToMany

Extends

Properties

protected

$morphType string

The type of the polymorphic relation.

Default: null
protected

$morphClass string

The class name of the morph type constraint.

Default: null
protected

$inverse bool

Indicates if we are connecting the inverse of the relation.

This primarily affects the morphClass constraint.

Default: null

Methods

public

__construct ( Builder $query , Model $parent , $name , $table , $foreignPivotKey , $relatedPivotKey , $parentKey , $relatedKey , $relationName , $inverse ) : void

Create a new morph to many relationship instance.

Parameters

  • $query Builder
  • $parent Model
  • $name string
  • $table string
  • $foreignPivotKey string
  • $relatedPivotKey string
  • $parentKey string
  • $relatedKey string
  • $relationName string|null
  • $inverse bool
protected

addWhereConstraints ( ) : $this

Set the where clause for the relation query.

public

addEagerConstraints ( array $models ) : void

Set the constraints for an eager load of the relation.

Parameters

  • $models array
protected

baseAttachRecord ( $id , $timed ) : array

Create a new pivot attachment record.

Parameters

  • $id int
  • $timed bool
public

getRelationExistenceQuery ( Builder $query , Builder $parentQuery , $columns ) : Builder

Add the constraints for a relationship count query.

Parameters

protected

getCurrentlyAttachedPivots ( ) : Collection

Get the pivot models that are currently attached.

public

newPivotQuery ( ) : Builder

Create a new query builder for the pivot table.

public

newPivot ( array $attributes , $exists ) : Pivot

Create a new pivot model instance.

Parameters

  • $attributes array
  • $exists bool
protected

aliasedPivotColumns ( ) : array

Get the pivot columns for the relation.

public

getMorphType ( ) : string

Get the foreign key "type" name.

public

getMorphClass ( ) : string

Get the class name of the parent model.

public

getInverse ( ) : bool

Get the indicator for a reverse relationship.