Pivot
class Pivot extends Model (View source)
Traits
Constants
CREATED_AT |
The name of the "created at" column. |
UPDATED_AT |
The name of the "updated at" column. |
Properties
protected array | $attributes | The model's attributes. |
from HasAttributes |
protected array | $original | The model attribute's original state. |
from HasAttributes |
protected array | $changes | The changed model attributes. |
from HasAttributes |
protected array | $casts | The attributes that should be cast to native types. |
from HasAttributes |
protected array | $dates | The attributes that should be mutated to dates. |
from HasAttributes |
protected string | $dateFormat | The storage format of the model's date columns. |
from HasAttributes |
protected array | $appends | The accessors to append to the model's array form. |
from HasAttributes |
static bool | $snakeAttributes | Indicates whether attributes are snake cased on arrays. |
from HasAttributes |
static protected array | $mutatorCache | The cache of the mutated attributes for each class. |
from HasAttributes |
protected array | $dispatchesEvents | The event map for the model. |
from HasEvents |
protected array | $observables | User exposed observable events. |
from HasEvents |
protected array | $relations | The loaded relationships for the model. |
from HasRelationships |
protected array | $touches | The relationships that should be touched on save. |
from HasRelationships |
static array | $manyMethods | The many to many relationship methods. |
from HasRelationships |
bool | $timestamps | Indicates if the model should be timestamped. |
from HasTimestamps |
$hidden | The attributes that should be hidden for serialization. |
from HidesAttributes | |
protected array | $visible | The attributes that should be visible in serialization. |
from HidesAttributes |
protected array | $fillable | The attributes that are mass assignable. |
from GuardsAttributes |
protected array | $guarded | The attributes that aren't mass assignable. |
|
static protected bool | $unguarded | Indicates if all mass assignment is enabled. |
from GuardsAttributes |
static protected array | $guardableColumns | The actual columns that exist on the database and can be guarded. |
from GuardsAttributes |
protected string | $connection | The connection name for the model. |
from Model |
protected string | $table | The table associated with the model. |
from Model |
protected string | $primaryKey | The primary key for the model. |
from Model |
protected string | $keyType | The "type" of the auto-incrementing ID. |
from Model |
bool | $incrementing | Indicates if the IDs are auto-incrementing. |
from Model |
protected array | $with | The relations to eager load on every query. |
from Model |
protected array | $withCount | The relationship counts that should be eager loaded on every query. |
from Model |
protected int | $perPage | The number of models to return for pagination. |
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 protected ConnectionResolverInterface | $resolver | The connection resolver instance. |
from Model |
static protected Dispatcher | $dispatcher | The event dispatcher instance. |
from Model |
static protected array | $booted | The array of booted models. |
from Model |
static protected array | $globalScopes | The array of global scopes on the model. |
from Model |
Model | $pivotParent | The parent model of the relationship. |
|
protected string | $foreignKey | The name of the foreign key column. |
|
protected string | $relatedKey | The name of the "other key" column. |
Methods
Add the date attributes to the attributes array.
Add the mutated attributes to the attributes array.
Add the casted attributes to the attributes array.
Get an attribute array of all arrayable attributes.
Get an attribute array of all arrayable values.
Get an attribute from the $attributes array.
Get a relationship value from a method.
Determine if a get mutator exists for an attribute.
Get the value of an attribute using its mutator.
Get the value of an attribute using its mutator for array conversion.
Cast an attribute to a native PHP type.
Set a given attribute on the model.
Determine if a set mutator exists for an attribute.
Determine if the given attribute is a date or date castable.
Set a given JSON attribute on the model.
Get an array attribute with the given key and value set.
Get an array attribute or return an empty array if it is not set.
Cast the given attribute to JSON.
Decode the given JSON back into an array or object.
Return a timestamp as DateTime object with time set to 00:00:00.
Determine if the given value is a standard date format.
Determine whether an attribute should be cast to a native type.
Determine whether a value is Date / DateTime castable for inbound manipulation.
Determine whether a value is JSON castable for inbound manipulation.
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.
Determine if the model or given attribute(s) have remained the same.
Determine if the model or given attribute(s) have been modified.
Determine if the given attributes were changed.
Determine if the new and old values for a given key are equivalent.
Append attributes to query when building a query.
Extract and cache all the mutated attributes of a class.
Get all of the attribute mutator methods.
Remove an observable event name.
Register a model event with the dispatcher.
Fire the given event for the model.
Fire a custom model event for the given event.
Register a new global scope on the model.
Define a one-to-one relationship.
Instantiate a new HasOne relationship.
Define a polymorphic one-to-one relationship.
Instantiate a new MorphOne relationship.
Define an inverse one-to-one or many relationship.
Instantiate a new BelongsTo relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Instantiate a new MorphTo relationship.
Retrieve the actual class name for a given morph class.
Define a one-to-many relationship.
Instantiate a new HasMany relationship.
Define a has-many-through relationship.
Instantiate a new HasManyThrough relationship.
Define a polymorphic one-to-many relationship.
Instantiate a new MorphMany relationship.
Define a many-to-many relationship.
Instantiate a new BelongsToMany relationship.
Define a polymorphic many-to-many relationship.
Instantiate a new HasManyThrough relationship.
Define a polymorphic, inverse many-to-many relationship.
Get the relationship name of the belongs to many.
Get the joining table name for a many-to-many relation.
Determine if the model touches a given relation.
Get the polymorphic relationship columns.
Create a new model instance for a related model.
Set the specific relationship in the model.
Set the entire relations array on the model.
Set the relationships that are touched on save.
Get the name of the "created at" column.
Get the name of the "updated at" column.
Add hidden attributes for the model.
Add visible attributes for the model.
Make the given, typically hidden, attributes visible.
Make the given, typically visible, attributes hidden.
Disable all mass assignable restrictions.
Run the given callable while being unguarded.
Determine if the given attribute may be mass assigned.
Determine if the given column is a valid, guardable column.
Get the fillable attributes of a given array.
Clear the list of booted models so they will be re-booted.
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.
Begin querying the model on a given connection.
Get all of the models from the database.
Eager load relations on the model if they are not already eager loaded.
Increment a column's value by a given amount.
Decrement a column's value by a given amount.
Run the increment or decrement method on the model.
Increment the underlying attribute value and sync with original.
Update the model in the database.
Perform any actions that are necessary after the model is saved.
Insert the given attributes and set the ID on the model.
Delete the pivot model record from the database.
Get a new query builder that doesn't have any global scopes or eager loading.
Get a new query builder with no relationships loaded.
Get a new query builder that doesn't have any global scopes.
Get a new query to restore one or more models by their queueable IDs.
Create a new pivot model instance.
Reload a fresh model instance from the database.
Reload the current model instance with fresh attributes from the database.
Resolve a connection instance.
Get the connection resolver instance.
Get the table associated with the model.
Get the foreign key column name.
Handle dynamic method calls into the model.
Handle dynamic static method calls into the method.
Create a new pivot model instance.
Create a new pivot model from raw values returned from a query.
Get the query builder for a delete operation on the pivot.
Get the "related key" column name.
Get the "related key" column name.
Set the key names for the pivot model instance.
Determine if the pivot model has timestamp attributes.
Details
array
attributesToArray()
Convert the model's attributes to an array.
protected array
addDateAttributesToArray(array $attributes)
Add the date attributes to the attributes array.
protected array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)
Add the mutated attributes to the attributes array.
protected array
addCastAttributesToArray(array $attributes, array $mutatedAttributes)
Add the casted attributes to the attributes array.
protected array
getArrayableAttributes()
Get an attribute array of all arrayable attributes.
protected array
getArrayableAppends()
Get all of the appendable values that are arrayable.
array
relationsToArray()
Get the model's relationships in array form.
protected array
getArrayableRelations()
Get an attribute array of all arrayable relations.
protected array
getArrayableItems(array $values)
Get an attribute array of all arrayable values.
mixed
getAttribute(string $key)
Get an attribute from the model.
mixed
getAttributeValue(string $key)
Get a plain attribute (not a relationship).
protected mixed
getAttributeFromArray(string $key)
Get an attribute from the $attributes array.
mixed
getRelationValue(string $key)
Get a relationship.
protected mixed
getRelationshipFromMethod(string $method)
Get a relationship value from a method.
bool
hasGetMutator(string $key)
Determine if a get mutator exists for an attribute.
protected mixed
mutateAttribute(string $key, mixed $value)
Get the value of an attribute using its mutator.
protected mixed
mutateAttributeForArray(string $key, mixed $value)
Get the value of an attribute using its mutator for array conversion.
protected mixed
castAttribute(string $key, mixed $value)
Cast an attribute to a native PHP type.
protected string
getCastType(string $key)
Get the type of cast for a model attribute.
$this
setAttribute(string $key, mixed $value)
Set a given attribute on the model.
bool
hasSetMutator(string $key)
Determine if a set mutator exists for an attribute.
protected bool
isDateAttribute(string $key)
Determine if the given attribute is a date or date castable.
$this
fillJsonAttribute(string $key, mixed $value)
Set a given JSON attribute on the model.
protected $this
getArrayAttributeWithValue(string $path, string $key, mixed $value)
Get an array attribute with the given key and value set.
protected array
getArrayAttributeByKey(string $key)
Get an array attribute or return an empty array if it is not set.
protected string
castAttributeAsJson(string $key, mixed $value)
Cast the given attribute to JSON.
protected string
asJson(mixed $value)
Encode the given value as JSON.
mixed
fromJson(string $value, bool $asObject = false)
Decode the given JSON back into an array or object.
protected Carbon
asDate(mixed $value)
Return a timestamp as DateTime object with time set to 00:00:00.
protected Carbon
asDateTime(mixed $value)
Return a timestamp as DateTime object.
protected bool
isStandardDateFormat(string $value)
Determine if the given value is a standard date format.
string
fromDateTime(DateTime|int $value)
Convert a DateTime to a storable string.
protected int
asTimestamp(mixed $value)
Return a timestamp as unix timestamp.
protected string
serializeDate(DateTimeInterface $date)
Prepare a date for array / JSON serialization.
array
getDates()
Get the attributes that should be converted to dates.
protected string
getDateFormat()
Get the format for database stored dates.
$this
setDateFormat(string $format)
Set the date format used by the model.
bool
hasCast(string $key, array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
array
getCasts()
Get the casts array.
protected bool
isDateCastable(string $key)
Determine whether a value is Date / DateTime castable for inbound manipulation.
protected bool
isJsonCastable(string $key)
Determine whether a value is JSON castable for inbound manipulation.
array
getAttributes()
Get all of the current attributes on the model.
$this
setRawAttributes(array $attributes, bool $sync = false)
Set the array of model attributes. No checking is done.
mixed|array
getOriginal(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
array
only(array|mixed $attributes)
Get a subset of the model's attributes.
$this
syncOriginal()
Sync the original attributes with the current.
$this
syncOriginalAttribute(string $attribute)
Sync a single original attribute with its current value.
$this
syncChanges()
Sync the changed attributes.
bool
isDirty(array|string|null $attributes = null)
Determine if the model or given attribute(s) have been modified.
bool
isClean(array|string|null $attributes = null)
Determine if the model or given attribute(s) have remained the same.
bool
wasChanged(array|string|null $attributes = null)
Determine if the model or given attribute(s) have been modified.
protected bool
hasChanges(array $changes, array|string|null $attributes = null)
Determine if the given attributes were changed.
array
getDirty()
Get the attributes that have been changed since last sync.
array
getChanges()
Get the attributes that were changed.
protected bool
originalIsEquivalent(string $key, mixed $current)
Determine if the new and old values for a given key are equivalent.
$this
append(array|string $attributes)
Append attributes to query when building a query.
$this
setAppends(array $appends)
Set the accessors to append to model arrays.
array
getMutatedAttributes()
Get the mutated attributes for a given instance.
static void
cacheMutatedAttributes(string $class)
Extract and cache all the mutated attributes of a class.
static protected array
getMutatorMethods(mixed $class)
Get all of the attribute mutator methods.
static void
observe(object|string $class)
Register an observer with the Model.
array
getObservableEvents()
Get the observable event names.
$this
setObservableEvents(array $observables)
Set the observable event names.
void
addObservableEvents(array|mixed $observables)
Add an observable event name.
void
removeObservableEvents(array|mixed $observables)
Remove an observable event name.
static protected void
registerModelEvent(string $event, Closure|string $callback)
Register a model event with the dispatcher.
protected mixed
fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
protected mixed|null
fireCustomModelEvent(string $event, string $method)
Fire a custom model event for the given event.
protected mixed
filterModelEventResults(mixed $result)
Filter the model event results.
static void
retrieved(Closure|string $callback)
Register a retrieved model event with the dispatcher.
static void
saving(Closure|string $callback)
Register a saving model event with the dispatcher.
static void
saved(Closure|string $callback)
Register a saved model event with the dispatcher.
static void
updating(Closure|string $callback)
Register an updating model event with the dispatcher.
static void
updated(Closure|string $callback)
Register an updated model event with the dispatcher.
static void
creating(Closure|string $callback)
Register a creating model event with the dispatcher.
static void
created(Closure|string $callback)
Register a created model event with the dispatcher.
static void
deleting(Closure|string $callback)
Register a deleting model event with the dispatcher.
static void
deleted(Closure|string $callback)
Register a deleted model event with the dispatcher.
static void
flushEventListeners()
Remove all of the event listeners for the model.
static Dispatcher
getEventDispatcher()
Get the event dispatcher instance.
static void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
static void
unsetEventDispatcher()
Unset the event dispatcher for models.
static mixed
addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null)
Register a new global scope on the model.
static bool
hasGlobalScope(Scope|string $scope)
Determine if a model has a global scope.
static Scope|Closure|null
getGlobalScope(Scope|string $scope)
Get a global scope registered with the model.
array
getGlobalScopes()
Get the global scopes for this class instance.
HasOne
hasOne(string $related, string $foreignKey = null, string $localKey = null)
Define a one-to-one relationship.
protected HasOne
newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasOne relationship.
MorphOne
morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null)
Define a polymorphic one-to-one relationship.
protected MorphOne
newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphOne relationship.
BelongsTo
belongsTo(string $related, string $foreignKey = null, string $ownerKey = null, string $relation = null)
Define an inverse one-to-one or many relationship.
protected BelongsTo
newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)
Instantiate a new BelongsTo relationship.
MorphTo
morphTo(string $name = null, string $type = null, string $id = null)
Define a polymorphic, inverse one-to-one or many relationship.
protected MorphTo
morphEagerTo(string $name, string $type, string $id)
Define a polymorphic, inverse one-to-one or many relationship.
protected MorphTo
morphInstanceTo(string $target, string $name, string $type, string $id)
Define a polymorphic, inverse one-to-one or many relationship.
protected MorphTo
newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation)
Instantiate a new MorphTo relationship.
static string
getActualClassNameForMorph(string $class)
Retrieve the actual class name for a given morph class.
protected string
guessBelongsToRelation()
Guess the "belongs to" relationship name.
HasMany
hasMany(string $related, string $foreignKey = null, string $localKey = null)
Define a one-to-many relationship.
protected HasMany
newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasMany relationship.
HasManyThrough
hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null)
Define a has-many-through relationship.
protected HasManyThrough
newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)
Instantiate a new HasManyThrough relationship.
MorphMany
morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null)
Define a polymorphic one-to-many relationship.
protected MorphMany
newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphMany relationship.
BelongsToMany
belongsToMany(string $related, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null, string $relation = null)
Define a many-to-many relationship.
protected BelongsToMany
newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string $relationName = null)
Instantiate a new BelongsToMany relationship.
MorphToMany
morphToMany(string $related, string $name, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null, bool $inverse = false)
Define a polymorphic many-to-many relationship.
protected MorphToMany
newMorphToMany(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string $relationName = null, bool $inverse = false)
Instantiate a new HasManyThrough relationship.
MorphToMany
morphedByMany(string $related, string $name, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null)
Define a polymorphic, inverse many-to-many relationship.
protected string
guessBelongsToManyRelation()
Get the relationship name of the belongs to many.
string
joiningTable(string $related)
Get the joining table name for a many-to-many relation.
bool
touches(string $relation)
Determine if the model touches a given relation.
void
touchOwners()
Touch the owning relations of the model.
protected array
getMorphs(string $name, string $type, string $id)
Get the polymorphic relationship columns.
string
getMorphClass()
Get the class name for polymorphic relations.
protected mixed
newRelatedInstance(string $class)
Create a new model instance for a related model.
array
getRelations()
Get all the loaded relations for the instance.
mixed
getRelation(string $relation)
Get a specified relationship.
bool
relationLoaded(string $key)
Determine if the given relation is loaded.
$this
setRelation(string $relation, mixed $value)
Set the specific relationship in the model.
$this
setRelations(array $relations)
Set the entire relations array on the model.
array
getTouchedRelations()
Get the relationships that are touched on save.
$this
setTouchedRelations(array $touches)
Set the relationships that are touched on save.
bool
touch()
Update the model's update timestamp.
protected void
updateTimestamps()
Update the creation and update timestamps.
$this
setCreatedAt(mixed $value)
Set the value of the "created at" attribute.
$this
setUpdatedAt(mixed $value)
Set the value of the "updated at" attribute.
Carbon
freshTimestamp()
Get a fresh timestamp for the model.
string
freshTimestampString()
Get a fresh timestamp for the model.
bool
usesTimestamps()
Determine if the model uses timestamps.
string
getCreatedAtColumn()
Get the name of the "created at" column.
string
getUpdatedAtColumn()
Get the name of the "updated at" column.
array
getHidden()
Get the hidden attributes for the model.
$this
setHidden(array $hidden)
Set the hidden attributes for the model.
void
addHidden(array|string|null $attributes = null)
Add hidden attributes for the model.
array
getVisible()
Get the visible attributes for the model.
$this
setVisible(array $visible)
Set the visible attributes for the model.
void
addVisible(array|string|null $attributes = null)
Add visible attributes for the model.
$this
makeVisible(array|string $attributes)
Make the given, typically hidden, attributes visible.
$this
makeHidden(array|string $attributes)
Make the given, typically visible, attributes hidden.
array
getFillable()
Get the fillable attributes for the model.
$this
fillable(array $fillable)
Set the fillable attributes for the model.
array
getGuarded()
Get the guarded attributes for the model.
$this
guard(array $guarded)
Set the guarded attributes for the model.
static void
unguard(bool $state = true)
Disable all mass assignable restrictions.
static void
reguard()
Enable the mass assignment restrictions.
static bool
isUnguarded()
Determine if current state is "unguarded".
static mixed
unguarded(callable $callback)
Run the given callable while being unguarded.
bool
isFillable(string $key)
Determine if the given attribute may be mass assigned.
bool
isGuarded(string $key)
Determine if the given key is guarded.
protected bool
isGuardableColumn(string $key)
Determine if the given column is a valid, guardable column.
bool
totallyGuarded()
Determine if the model is totally guarded.
protected array
fillableFromArray(array $attributes)
Get the fillable attributes of a given array.
in
Model at line 146
void
__construct(array $attributes = [])
Create a new Eloquent model instance.
in
Model at line 160
protected void
bootIfNotBooted()
Check if the model needs to be booted and if so, do it.
in
Model at line 178
static protected void
boot()
The "booting" method of the model.
in
Model at line 188
static protected void
bootTraits()
Boot all of the bootable traits on the model.
in
Model at line 204
static void
clearBootedModels()
Clear the list of booted models so they will be re-booted.
in
Model at line 219
$this
fill(array $attributes)
Fill the model with an array of attributes.
in
Model at line 245
$this
forceFill(array $attributes)
Fill the model with an array of attributes. Force mass assignment.
in
Model at line 258
string
qualifyColumn(string $column)
Qualify the given column name by the model's table.
in
Model at line 273
protected string
removeTableFromKey(string $key)
Remove the table name from a given key.
in
Model at line 285
Model
newInstance(array $attributes = [], bool $exists = false)
Create a new instance of the given model.
in
Model at line 308
Model
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance that is existing.
in
Model at line 327
static Builder
on(string|null $connection = null)
Begin querying the model on a given connection.
in
Model at line 344
static Builder
onWriteConnection()
Begin querying the model on the write connection.
in
Model at line 357
static Collection|Model[]
all(array|mixed $columns = ['*'])
Get all of the models from the database.
in
Model at line 370
static Builder|Model
with(array|string $relations)
Begin querying a model with eager loading.
in
Model at line 383
$this
load(array|string $relations)
Eager load relations on the model.
in
Model at line 400
$this
loadMissing(array|string $relations)
Eager load relations on the model if they are not already eager loaded.
in
Model at line 417
protected int
increment(string $column, int $amount = 1, array $extra = [])
Increment a column's value by a given amount.
in
Model at line 430
protected int
decrement(string $column, int $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
in
Model at line 444
protected int
incrementOrDecrement(string $column, int $amount, array $extra, string $method)
Run the increment or decrement method on the model.
in
Model at line 468
protected void
incrementOrDecrementAttributeValue(string $column, int $amount, array $extra, string $method)
Increment the underlying attribute value and sync with original.
in
Model at line 484
bool
update(array $attributes = [], array $options = [])
Update the model in the database.
in
Model at line 498
bool
push()
Save the model and all of its relationships.
in
Model at line 527
bool
save(array $options = [])
Save the model to the database.
in
Model at line 576
bool
saveOrFail(array $options = [])
Save the model to the database using transaction.
in
Model at line 589
protected void
finishSave(array $options)
Perform any actions that are necessary after the model is saved.
in
Model at line 606
protected bool
performUpdate(Builder $query)
Perform a model update operation.
in
Model at line 656
protected mixed
getKeyForSaveQuery()
Get the primary key value for a save query.
in
Model at line 668
protected bool
performInsert(Builder $query)
Perform a model insert operation.
in
Model at line 720
protected void
insertAndSetId(Builder $query, array $attributes)
Insert the given attributes and set the ID on the model.
in
Model at line 733
static int
destroy(array|int $ids)
Destroy the models for the given IDs.
bool|null
delete()
Delete the pivot model record from the database.
in
Model at line 802
bool|null
forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when trait is missing.
in
Model at line 812
protected void
performDeleteOnModel()
Perform the actual delete query on this model instance.
in
Model at line 824
static Builder
query()
Begin querying the model.
in
Model at line 834
Builder
newQuery()
Get a new query builder for the model's table.
in
Model at line 844
Builder|Model
newModelQuery()
Get a new query builder that doesn't have any global scopes or eager loading.
in
Model at line 856
Builder
newQueryWithoutRelationships()
Get a new query builder with no relationships loaded.
in
Model at line 869
Builder
registerGlobalScopes(Builder $builder)
Register the global scopes for this builder instance.
in
Model at line 883
Builder|Model
newQueryWithoutScopes()
Get a new query builder that doesn't have any global scopes.
in
Model at line 896
Builder
newQueryWithoutScope(Scope|string $scope)
Get a new query instance without a given scope.
in
Model at line 909
Builder
newQueryForRestoration(array|int $ids)
Get a new query to restore one or more models by their queueable IDs.
in
Model at line 924
Builder|Model
newEloquentBuilder(Builder $query)
Create a new Eloquent query builder for the model.
in
Model at line 934
protected Builder
newBaseQueryBuilder()
Get a new query builder instance for the connection.
in
Model at line 949
Collection
newCollection(array $models = [])
Create a new Eloquent Collection instance.
in
Model at line 964
Pivot
newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)
Create a new pivot model instance.
in
Model at line 975
array
toArray()
Get the instance as an array.
in
Model at line 988
string
toJson(int $options = 0)
Convert the object to its JSON representation.
array
jsonSerialize()
Convert the object into something JSON serializable.
Model|null
fresh(array|string $with = [])
Reload a fresh model instance from the database.
$this
refresh()
Reload the current model instance with fresh attributes from the database.
Model
replicate(array $except = null)
Clone the model into a new, non-existing instance.
bool
is(Model|null $model)
Determine if two models have the same ID and belong to the same table.
bool
isNot(Model|null $model)
Determine if two models are not the same.
Connection
getConnection()
Get the database connection for the model.
string
getConnectionName()
Get the current connection name for the model.
$this
setConnection(string $name)
Set the connection associated with the model.
static Connection
resolveConnection(string|null $connection = null)
Resolve a connection instance.
static ConnectionResolverInterface
getConnectionResolver()
Get the connection resolver instance.
static void
setConnectionResolver(ConnectionResolverInterface $resolver)
Set the connection resolver instance.
static void
unsetConnectionResolver()
Unset the connection resolver for models.
string
getTable()
Get the table associated with the model.
$this
setTable(string $table)
Set the table associated with the model.
string
getKeyName()
Get the primary key for the model.
$this
setKeyName(string $key)
Set the primary key for the model.
string
getQualifiedKeyName()
Get the table qualified key name.
string
getKeyType()
Get the auto-incrementing key type.
$this
setKeyType(string $type)
Set the data type for the primary key.
bool
getIncrementing()
Get the value indicating whether the IDs are incrementing.
$this
setIncrementing(bool $value)
Set whether IDs are incrementing.
mixed
getKey()
Get the value of the model's primary key.
mixed
getQueueableId()
Get the queueable identity for the entity.
string|null
getQueueableConnection()
Get the connection of the entity.
mixed
getRouteKey()
Get the value of the model's route key.
string
getRouteKeyName()
Get the route key for the model.
Model|null
resolveRouteBinding(mixed $value)
Retrieve the model for a bound value.
string
getForeignKey()
Get the foreign key column name.
int
getPerPage()
Get the number of models to return per page.
$this
setPerPage(int $perPage)
Set the number of models to return per page.
mixed
__get(string $key)
Dynamically retrieve attributes on the model.
void
__set(string $key, mixed $value)
Dynamically set attributes on the model.
bool
offsetExists(mixed $offset)
Determine if the given attribute exists.
mixed
offsetGet(mixed $offset)
Get the value for a given offset.
void
offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
void
offsetUnset(mixed $offset)
Unset the value for a given offset.
bool
__isset(string $key)
Determine if an attribute or relation exists on the model.
void
__unset(string $key)
Unset an attribute on the model.
mixed
__call(string $method, array $parameters)
Handle dynamic method calls into the model.
static mixed
__callStatic(string $method, array $parameters)
Handle dynamic static method calls into the method.
string
__toString()
Convert the model to its string representation.
void
__wakeup()
When a model is being unserialized, check if it needs to be booted.
static Pivot
fromAttributes(Model $parent, array $attributes, string $table, bool $exists = false)
Create a new pivot model instance.
static Pivot
fromRawAttributes(Model $parent, array $attributes, string $table, bool $exists = false)
Create a new pivot model from raw values returned from a query.
protected Builder
getDeleteQuery()
Get the query builder for a delete operation on the pivot.
string
getRelatedKey()
Get the "related key" column name.
string
getOtherKey()
Get the "related key" column name.
$this
setPivotKeys(string $foreignKey, string $relatedKey)
Set the key names for the pivot model instance.
bool
hasTimestampAttributes()
Determine if the pivot model has timestamp attributes.