MorphPivot
class MorphPivot extends Pivot (View source)
Constants
CREATED_AT |
The name of the "created at" column. |
UPDATED_AT |
The name of the "updated at" column. |
Properties
bool | $incrementing | Indicates if the IDs are auto-incrementing. | from Model |
bool | $timestamps | Indicates if the model should be timestamped. | from Model |
bool | $exists | Indicates if the model exists. | from Model |
bool | $wasRecentlyCreated | Indicates if the model was inserted during the current request lifecycle. | from Model |
static bool | $snakeAttributes | Indicates whether attributes are snake cased on arrays. | from Model |
static array | $manyMethods | The many to many relationship methods. | from Model |
Methods
Create a new pivot model instance.
Clear the list of booted models so they will be re-booted.
Register an observer with the Model.
Fill the model with an array of attributes. Force mass assignment.
Create a new instance of the given model.
Create a new model instance that is existing.
Create a collection of models from plain arrays.
Create a collection of models from a raw query.
Save a new model and return the instance.
Save a new model and return the instance. Allow mass-assignment.
Begin querying the model on a given connection.
Get all of the models from the database.
Reload a fresh model instance from the database.
Append attributes to query when building a query.
Define a one-to-one relationship.
Define a polymorphic one-to-one relationship.
Define an inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Retrieve the fully qualified class name from a slug.
Define a one-to-many relationship.
Define a has-many-through relationship.
Define a polymorphic one-to-many relationship.
Define a many-to-many relationship.
Define a polymorphic many-to-many relationship.
Define a polymorphic, inverse many-to-many relationship.
Get the joining table name for a many-to-many relation.
Delete the pivot model record from the database.
Register an updating model event with the dispatcher.
Register an updated model event with the dispatcher.
Register a creating model event with the dispatcher.
Register a created model event with the dispatcher.
Register a deleting model event with the dispatcher.
Register a deleted model event with the dispatcher.
Save the model to the database using transaction.
Get a new query builder that doesn't have any global scopes.
Create a new Eloquent Collection instance.
Create a new pivot model instance.
Add hidden attributes for the model.
Make the given, typically hidden, attributes visible.
Add visible attributes for the model.
Run the given callable while being unguarded.
Set the relationships that are touched on save.
Decode the given JSON back into an array or object.
Set the array of model attributes. No checking is done.
Get the model's original attribute values.
Sync a single original attribute with its current value.
Determine if the model or given attribute(s) have been modified.
Set the specific relationship in the model.
Resolve a connection instance.
Get the connection resolver instance.
Extract and cache all the mutated attributes of a class.
Handle dynamic method calls into the model.
Handle dynamic static method calls into the method.
Set the key names for the pivot model instance.
Set the morph type for the pivot.
Set the morph class for the pivot.
Details
void
__construct(
Model $parent,
array $attributes,
string $table,
bool $exists = false)
Create a new pivot model instance.
static
ScopeInterface|null
getGlobalScope(
ScopeInterface $scope)
Get a global scope registered with the model.
$this
forceFill(
array $attributes)
Fill the model with an array of attributes. Force mass assignment.
Model
newInstance(
array $attributes = array(),
bool $exists = false)
Create a new instance of the given model.
Model
newFromBuilder(
array $attributes = array(),
string|null $connection = null)
Create a new model instance that is existing.
static
Collection
hydrate(
array $items,
string|null $connection = null)
Create a collection of models from plain arrays.
static
Collection
hydrateRaw(
string $query,
array $bindings = array(),
string|null $connection = null)
Create a collection of models from a raw query.
static
Model
forceCreate(
array $attributes)
Save a new model and return the instance. Allow mass-assignment.
static
Collection|Model[]
all(
array|mixed $columns = array('*'))
Get all of the models from the database.
HasOne
hasOne(
string $related,
string $foreignKey = null,
string $localKey = null)
Define a one-to-one relationship.
MorphOne
morphOne(
string $related,
string $name,
string $type = null,
string $id = null,
string $localKey = null)
Define a polymorphic one-to-one relationship.
BelongsTo
belongsTo(
string $related,
string $foreignKey = null,
string $otherKey = null,
string $relation = null)
Define an inverse one-to-one or many relationship.
MorphTo
morphTo(
string $name = null,
string $type = null,
string $id = null)
Define a polymorphic, inverse one-to-one or many relationship.
string
getActualClassNameForMorph(
string $class)
Retrieve the fully qualified class name from a slug.
HasMany
hasMany(
string $related,
string $foreignKey = null,
string $localKey = null)
Define a one-to-many relationship.
HasManyThrough
hasManyThrough(
string $related,
string $through,
string|null $firstKey = null,
string|null $secondKey = null,
string|null $localKey = null)
Define a has-many-through relationship.
MorphMany
morphMany(
string $related,
string $name,
string $type = null,
string $id = null,
string $localKey = null)
Define a polymorphic one-to-many relationship.
BelongsToMany
belongsToMany(
string $related,
string $table = null,
string $foreignKey = null,
string $otherKey = null,
string $relation = null)
Define a many-to-many relationship.
MorphToMany
morphToMany(
string $related,
string $name,
string $table = null,
string $foreignKey = null,
string $otherKey = null,
bool $inverse = false)
Define a polymorphic many-to-many relationship.
MorphToMany
morphedByMany(
string $related,
string $name,
string $table = null,
string $foreignKey = null,
string $otherKey = null)
Define a polymorphic, inverse many-to-many relationship.
bool|null
forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when trait is missing.
static
void
saving(
Closure|string $callback,
int $priority)
Register a saving model event with the dispatcher.
static
void
saved(
Closure|string $callback,
int $priority)
Register a saved model event with the dispatcher.
static
void
updating(
Closure|string $callback,
int $priority)
Register an updating model event with the dispatcher.
static
void
updated(
Closure|string $callback,
int $priority)
Register an updated model event with the dispatcher.
static
void
creating(
Closure|string $callback,
int $priority)
Register a creating model event with the dispatcher.
static
void
created(
Closure|string $callback,
int $priority)
Register a created model event with the dispatcher.
static
void
deleting(
Closure|string $callback,
int $priority)
Register a deleting model event with the dispatcher.
static
void
deleted(
Closure|string $callback,
int $priority)
Register a deleted model event with the dispatcher.
Builder
newQueryWithoutScope(
ScopeInterface $scope)
Get a new query instance without a given scope.
Builder
removeGlobalScopes(
Builder $builder)
Remove all of the global scopes from an Eloquent builder.
Builder|Model
newEloquentBuilder(
Builder $query)
Create a new Eloquent query builder for the model.
Pivot
newPivot(
Model $parent,
array $attributes,
string $table,
bool $exists)
Create a new pivot model instance.
mixed
fromJson(
string $value,
bool $asObject = false)
Decode the given JSON back into an array or object.
$this
setRawAttributes(
array $attributes,
bool $sync = false)
Set the array of model attributes. No checking is done.
array
getOriginal(
string|null $key = null,
mixed $default = null)
Get the model's original attribute values.
$this
syncOriginalAttribute(
string $attribute)
Sync a single original attribute with its current value.
bool
isDirty(
array|string|null $attributes = null)
Determine if the model or given attribute(s) have been modified.
static
void
setConnectionResolver(
ConnectionResolverInterface $resolver)
Set the connection resolver instance.
static
void
cacheMutatedAttributes(
string $class)
Extract and cache all the mutated attributes of a class.
static
mixed
__callStatic(
string $method,
array $parameters)
Handle dynamic static method calls into the method.
$this
setPivotKeys(
string $foreignKey,
string $otherKey)
Set the key names for the pivot model instance.