October\Rain\Database\Relations\BelongsToMany

Source: ~/vendor/october/rain/src/Database/Relations/BelongsToMany.php

Extends:

  • Illuminate\Database\Eloquent\Relations\BelongsToMany
  • Illuminate\Database\Eloquent\Relations\Relation

Public properties

public boolean $countMode

This relation object is a 'count' helper.

public boolean $orphanMode

When a join is not used, don't select aliased columns.

Show inherited public properties

Inherited public properties

  • public bool $withTimestamps - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Indicates if timestamps are available on the pivot table.
  • public static array $morphMap - defined in Illuminate\Database\Eloquent\Relations\Relation. An array to map class names to their morph names in database.

Protected properties

There are no protected properties in the class.

Show inherited protected properties

Inherited protected properties

  • protected string $table - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The intermediate table for the relation.
  • protected string $foreignPivotKey - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The foreign key of the parent model.
  • protected string $relatedPivotKey - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The associated key of the relation.
  • protected string $parentKey - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The key name of the parent model.
  • protected string $relatedKey - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The key name of the related model.
  • protected string $relationName - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The "name" of the relationship.
  • protected array $pivotColumns - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The pivot table columns to retrieve.
  • protected array $pivotWheres - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Any pivot table restrictions for where clauses.
  • protected array $pivotWhereIns - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Any pivot table restrictions for whereIn clauses.
  • protected string $pivotCreatedAt - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The custom pivot table column for the created_at timestamp.
  • protected string $pivotUpdatedAt - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The custom pivot table column for the updated_at timestamp.
  • protected string $using - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The class name of the custom pivot model to use for the relationship.
  • protected string $accessor - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The name of the accessor to use for the "pivot" relationship.
  • protected static int $selfJoinCount - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. The count of self joins.
  • protected Illuminate\Database\Eloquent\Builder $query - defined in Illuminate\Database\Eloquent\Relations\Relation. The Eloquent query builder instance.
  • protected Illuminate\Database\Eloquent\Model $parent - defined in Illuminate\Database\Eloquent\Relations\Relation. The parent model instance.
  • protected Illuminate\Database\Eloquent\Model $related - defined in Illuminate\Database\Eloquent\Relations\Relation. The related model instance.
  • protected static bool $constraints - defined in Illuminate\Database\Eloquent\Relations\Relation. Indicates if the relation is adding constraints.
  • protected static array $macros - defined in Illuminate\Database\Eloquent\Relations\Relation. The registered string macros.

Public methods

public void __construct(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $relationName, $relatedKey, $relationName=NULL)

Create a new belongs to many relationship instance.

Parameters
  • Illuminate\Database\Eloquent\Builder $query
  • Illuminate\Database\Eloquent\Model $parent
  • string $table
  • string $foreignPivotKey
  • string $relatedPivotKey
  • string $relationName
  • $relatedKey
  • $relationName

public void add($model, $sessionKey=NULL, $pivotData=array())

Adds a model to this relationship type.

Parameters
  • $model
  • $sessionKey
  • $pivotData

public void addDefinedConstraints()

Set the defined constraints on the relation query.

public void addDefinedConstraintsToQuery(October\Rain\Database\QueryBuilder $query, array $args=NULL)

Add query based constraints.

Parameters

public void addDefinedConstraintsToRelation(Illuminate\Database\Eloquent\Relations\Relation $relation, array $args=NULL)

Add relation based constraints.

Parameters
  • Illuminate\Database\Eloquent\Relations\Relation $relation
  • array $args

public October\Rain\Support\Collection allRelatedIds(string $sessionKey=NULL)

Get all of the IDs for the related models, with deferred binding support

Parameters
  • string $sessionKey

public void attach(mixed $id, array $attributes=array(), bool $touch=true)

Override attach() method of BelongToMany relation. This is necessary in order to fire 'model.relation.beforeAttach', 'model.relation.afterAttach' events

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

public void create($attributes=array(), $pivotData=array(), $sessionKey=NULL)

Create a new instance of this related model with deferred binding support.

Parameters
  • $attributes
  • $pivotData
  • $sessionKey

public int|void detach(null $ids=NULL, bool $touch=true)

Override detach() method of BelongToMany relation. This is necessary in order to fire 'model.relation.beforeDetach', 'model.relation.afterDetach' events

Parameters
  • null $ids
  • bool $touch

public string getForeignKey()

Get the fully qualified foreign key for the relation.

public string getOtherKey()

Get the fully qualified "other key" for the relation.

public void getRelatedIds($sessionKey=NULL)
Parameters
  • $sessionKey

public void getSimpleValue()

Helper for getting this relationship simple value, generally useful with form values.

public Illuminate\Database\Eloquent\Relations\Pivot newPivot(array $attributes=array(), bool $exists=false)

Create a new pivot model instance.

Parameters
  • array $attributes
  • bool $exists

public Illuminate\Contracts\Pagination\LengthAwarePaginator paginate(int $perPage=15, int $currentPage=NULL, array $columns=array( 0=>'*'), string $pageName='page')

Get a paginator for the "select" statement. Complies with October Rain.

Parameters
  • int $perPage
  • int $currentPage
  • array $columns
  • string $pageName

public void remove($model, $sessionKey=NULL)

Removes a model from this relationship type.

Parameters
  • $model
  • $sessionKey

public void save($model, $pivotData=array(), $sessionKey=NULL)

Save the supplied related model with deferred binding support.

Parameters
  • $model
  • $pivotData
  • $sessionKey

public void setSimpleValue($value)

Helper for setting this relationship using various expected values. For example, $model->relation = $value;

Parameters
  • $value

public Illuminate\Database\Query\Builder withDeferred($sessionKey)

Returns the model query with deferred bindings added

Parameters
  • $sessionKey

Show inherited public methods

Inherited public methods

  • public mixed __call(string $method, array $parameters) - defined in Illuminate\Database\Eloquent\Relations\Relation. Handle dynamic method calls to the relationship.
  • public static mixed __callStatic(string $method, array $parameters) - defined in Illuminate\Database\Eloquent\Relations\Relation. Dynamically handle calls to the class.
  • public void __clone() - defined in Illuminate\Database\Eloquent\Relations\Relation. Force a clone of the underlying query builder when cloning.
  • public void addConstraints() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set the base constraints on the relation query.
  • public void addEagerConstraints(array $models) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set the constraints for an eager load of the relation.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany as(string $accessor) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Specify the custom pivot accessor to use for the relationship.
  • public bool chunk(int $count, callable $callback) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Chunk the results of the query.
  • public array createMany(array $records, array $joinings=array()) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create an array of new instances of the related models.
  • public string createdAt() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the name of the "created at" column.
  • public Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|null find(mixed $id, array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Find a related model by its primary key.
  • public Illuminate\Database\Eloquent\Collection findMany(mixed $ids, array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Find multiple related models by their primary keys.
  • public Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection findOrFail(mixed $id, array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Find a related model by its primary key or throw an exception.
  • public Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model findOrNew(mixed $id, array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Find a related model by its primary key or return new instance of the related model.
  • public mixed first(array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Execute the query and get the first result.
  • public Illuminate\Database\Eloquent\Model firstOrCreate(array $attributes, array $joining=array(), bool $touch=true) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the first related record matching the attributes or create it.
  • public Illuminate\Database\Eloquent\Model|static firstOrFail(array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Execute the query and get the first result or throw an exception.
  • public Illuminate\Database\Eloquent\Model firstOrNew(array $attributes) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the first related model record matching the attributes or instantiate it.
  • public Illuminate\Database\Eloquent\Collection get(array $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Execute the query as a "select" statement.
  • public Illuminate\Database\Query\Builder getBaseQuery() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the base query builder driving the Eloquent builder.
  • public Illuminate\Database\Eloquent\Collection getEager() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the relationship for eager loading.
  • public string getExistenceCompareKey() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the key for comparing against the parent key in "has" query.
  • public string getForeignPivotKeyName() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the foreign key for the relation.
  • public static string|null getMorphedModel(string $alias) - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the model associated with a custom polymorphic type.
  • public Illuminate\Database\Eloquent\Model getParent() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the parent model of the relation.
  • public string getPivotAccessor() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the name of the pivot accessor for this relationship.
  • public string getQualifiedForeignPivotKeyName() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the fully qualified foreign key for the relation.
  • public string getQualifiedParentKeyName() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the fully qualified parent key name for the relation.
  • public string getQualifiedRelatedPivotKeyName() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the fully qualified "related key" for the relation.
  • public Illuminate\Database\Eloquent\Builder getQuery() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the underlying query for the relation.
  • public Illuminate\Database\Eloquent\Model getRelated() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the related model of the relation.
  • public string getRelatedPivotKeyName() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the "related key" for the relation.
  • public string getRelationCountHash() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get a relationship join table hash.
  • public Illuminate\Database\Eloquent\Builder getRelationExistenceCountQuery(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parentQuery) - defined in Illuminate\Database\Eloquent\Relations\Relation. Add the constraints for a relationship count query.
  • public Illuminate\Database\Eloquent\Builder getRelationExistenceQuery(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parentQuery, array|mixed $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Add the constraints for a relationship query.
  • public Illuminate\Database\Eloquent\Builder getRelationExistenceQueryForSelfJoin(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parentQuery, array|mixed $columns=array( 0=>'*')) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Add the constraints for a relationship query on the same table.
  • public string getRelationName() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the relationship name for the relationship.
  • public mixed getResults() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the results of the relationship.
  • public string getTable() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the intermediate table for the relationship.
  • public static bool hasMacro(string $name) - defined in Illuminate\Database\Eloquent\Relations\Relation. Checks if macro is registered.
  • public array initRelation(array $models, string $relation) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Initialize the relation on a set of models.
  • public static void macro(string $name, object|callable $macro) - defined in Illuminate\Database\Eloquent\Relations\Relation. Register a custom macro.
  • public mixed macroCall(string $method, array $parameters) - defined in Illuminate\Database\Eloquent\Relations\Relation. Dynamically handle calls to the class.
  • public array match(array $models, Illuminate\Database\Eloquent\Collection $results, string $relation) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Match the eagerly loaded results to their parents.
  • public static void mixin(object $mixin) - defined in Illuminate\Database\Eloquent\Relations\Relation. Mix another object into the class.
  • public static array morphMap(array|null $map=NULL, bool $merge=true) - defined in Illuminate\Database\Eloquent\Relations\Relation. Set or get the morph map for polymorphic relations.
  • public Illuminate\Database\Eloquent\Relations\Pivot newExistingPivot(array $attributes=array()) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create a new existing pivot model instance.
  • public Illuminate\Database\Query\Builder newPivotStatement() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get a new plain query builder for the pivot table.
  • public Illuminate\Database\Query\Builder newPivotStatementForId(mixed $id) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get a new pivot statement for a given "other" ID.
  • public static mixed noConstraints(Closure $callback) - defined in Illuminate\Database\Eloquent\Relations\Relation. Run a callback with constraints disabled on the relation.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany orWherePivot(string $column, string $operator=NULL, mixed $value=NULL) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set an "or where" clause for a pivot table column.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany orWherePivotIn(string $column, mixed $values) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set an "or where in" clause for a pivot table column.
  • public int rawUpdate(array $attributes=array()) - defined in Illuminate\Database\Eloquent\Relations\Relation. Run a raw update against the base query.
  • public string relatedUpdatedAt() - defined in Illuminate\Database\Eloquent\Relations\Relation. Get the name of the related model's "updated at" column.
  • public array saveMany(Illuminate\Support\Collection|array $models, array $pivotAttributes=array()) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Save an array of new models and attach them to the parent model.
  • public Illuminate\Contracts\Pagination\Paginator simplePaginate(int $perPage=NULL, array $columns=array( 0=>'*'), string $pageName='page', int|null $page=NULL) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Paginate the given query into a simple paginator.
  • public array sync(Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids, bool $detaching=true) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Sync the intermediate tables with a list of IDs or collection of models.
  • public array syncWithoutDetaching(Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Sync the intermediate tables with a list of IDs without detaching.
  • public array toggle(mixed $ids, bool $touch=true) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Toggles a model (or models) from the parent.
  • public void touch() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Touch all of the related models for the relationship.
  • public void touchIfTouching() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. If we're touching the parent model, touch.
  • public int updateExistingPivot(mixed $id, array $attributes, bool $touch=true) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Update an existing pivot record on the table.
  • public Illuminate\Database\Eloquent\Model updateOrCreate(array $attributes, array $values=array(), array $joining=array(), bool $touch=true) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create or update a related record matching the attributes, and fill it with values.
  • public string updatedAt() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the name of the "updated at" column.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany using(string $class) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Specify the custom pivot model to use for the relationship.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany wherePivot(string $column, string $operator=NULL, mixed $value=NULL, string $boolean='and') - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set a where clause for a pivot table column.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany wherePivotIn(string $column, mixed $values, string $boolean='and', bool $not=false) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set a "where in" clause for a pivot table column.
  • public $this withPivot(array|mixed $columns) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set the columns on the pivot table to retrieve.
  • public Illuminate\Database\Eloquent\Relations\BelongsToMany withTimestamps(mixed $createdAt=NULL, mixed $updatedAt=NULL) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Specify that the pivot table has creation and update timestamps.

Protected methods

protected Illuminate\Database\Query\Expression getWithDeferredQualifiedKeyName()

Returns the related "slave id" key in a database friendly format.

protected Illuminate\Database\Eloquent\Relations\BelongsToMany shouldSelect(array $columns=array( 0=>'*'))

Get the select columns for the relation query.

Parameters
  • array $columns

Show inherited protected methods

Inherited protected methods

  • protected array addTimestampsToAttachment(array $record, bool $exists=false) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set the creation and update timestamps on an attach record.
  • protected $this addWhereConstraints() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set the where clause for the relation query.
  • protected array aliasedPivotColumns() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the pivot columns for the relation.
  • protected array attachNew(array $records, array $current, bool $touch=true) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Attach all of the records that aren't in the given current records.
  • protected array baseAttachRecord(int $id, bool $timed) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create a new pivot attachment record.
  • protected array buildDictionary(Illuminate\Database\Eloquent\Collection $results) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Build model dictionary keyed by the relation's foreign key.
  • protected static array|null buildMorphMapFromModels(array $models=NULL) - defined in Illuminate\Database\Eloquent\Relations\Relation. Builds a table-keyed array from model class names.
  • protected array castAttributes(array $attributes) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Cast the given pivot attributes.
  • protected mixed castKey(mixed $key) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Cast the given key to an integer if it is numeric.
  • protected array castKeys(array $keys) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Cast the given keys to integers if they are numeric and string otherwise.
  • protected array extractAttachIdAndAttributes(mixed $key, mixed $value, array $attributes) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the attach record ID and extra attributes.
  • protected array formatAttachRecord(int $key, mixed $value, array $attributes, bool $hasTimestamps) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create a full attachment record payload.
  • protected array formatAttachRecords(array $ids, array $attributes) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create an array of records to insert into the pivot table.
  • protected array formatRecordsList(array $records) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Format the sync / toggle record list so that it is keyed by ID.
  • protected array getKeys(array $models, string $key=NULL) - defined in Illuminate\Database\Eloquent\Relations\Relation. Get all of the primary keys for an array of models.
  • protected string guessInverseRelation() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Attempt to guess the name of the inverse of the relation.
  • protected bool hasPivotColumn(string $column) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Determine whether the given column is defined as a pivot column.
  • protected void hydratePivotRelation(array $models) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Hydrate the pivot table relationship on the models.
  • protected array migratePivotAttributes(Illuminate\Database\Eloquent\Model $model) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get the pivot attributes from a model.
  • protected Illuminate\Database\Query\Builder newPivotQuery() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Create a new query builder for the pivot table.
  • protected array parseIds(mixed $value) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Get all of the IDs from the given mixed value.
  • protected $this performJoin(Illuminate\Database\Eloquent\Builder|null $query=NULL) - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Set the join clause for the relation query.
  • protected bool touchingParent() - defined in Illuminate\Database\Eloquent\Relations\BelongsToMany. Determine if we should touch the parent on sync.