Pivot
class Pivot extends Model
Traits
Provides the ability to transform a model to a JSON resource.
Constants
| protected IGNORE_ON_TOUCH_CONTEXT_KEY |
Context key for storing models that should ignore touch. |
| protected BROADCASTING_CONTEXT_KEY |
Context key for storing whether broadcasting is enabled. |
| protected EVENTS_DISABLED_CONTEXT_KEY |
Context key for storing whether events are disabled. |
| protected MISSING_ATTRIBUTE_ACCESS_SUPPRESSED_CONTEXT_KEY |
Context key for suppressing missing attribute violations during existence checks. |
| UNGUARDED_CONTEXT_KEY |
Context key for storing whether mass assignment is unguarded. |
| CREATED_AT |
The name of the "created at" column. |
| UPDATED_AT |
The name of the "updated at" column. |
Properties
| protected array<string, mixed> | $attributes | The model's attributes. |
from HasAttributes |
| protected array<string, mixed> | $original | The model attribute's original state. |
from HasAttributes |
| protected array<string, mixed> | $changes | The changed model attributes. |
from HasAttributes |
| protected array<string, mixed> | $previous | The previous state of the changed model attributes. |
from HasAttributes |
| protected array<string, string> | $casts | The attributes that should be cast. |
from HasAttributes |
| protected array | $classCastCache | The attributes that have been cast using custom classes. |
from HasAttributes |
| protected array | $attributeCastCache | The attributes that have been cast using "Attribute" return type mutators. |
from HasAttributes |
| protected array|null | $mergedCastsCache | The cached merged casts array for this instance. |
from HasAttributes |
| protected array | $castMetadataCache | The cached results of cast metadata predicate methods for this instance. |
from HasAttributes |
| static protected string[] | $primitiveCastTypes | The built-in, primitive cast types supported by Eloquent. |
from HasAttributes |
| protected string|null | $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 |
| static protected array | $attributeMutatorCache | The cache of the "Attribute" return type marked mutated attributes for each class. |
from HasAttributes |
| static protected array | $getAttributeMutatorCache | The cache of the "Attribute" return type marked mutated, gettable attributes for each class. |
from HasAttributes |
| static protected array | $setAttributeMutatorCache | The cache of the "Attribute" return type marked mutated, settable attributes for each class. |
from HasAttributes |
| static protected array | $casterCache | The cache of the resolved custom caster class instances. |
from HasAttributes |
| static protected array | $castTypeCache | The cache of the converted cast types. |
from HasAttributes |
| static Encrypter|null | $encrypter | The encrypter instance that is used to encrypt attributes. |
from HasAttributes |
| protected array<string, class-string> | $dispatchesEvents | The event map for the model. |
from HasEvents |
| protected string[] | $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 |
| protected Closure|null | $relationAutoloadCallback | The relationship autoloader callback. |
from HasRelationships |
| protected mixed | $relationAutoloadContext | The relationship autoloader callback context. |
from HasRelationships |
| static string[] | $manyMethods | The many to many relationship methods. |
from HasRelationships |
| static protected array | $relationResolvers | The relation resolver callbacks. |
from HasRelationships |
| bool | $timestamps | Indicates if the model should be timestamped. |
from HasTimestamps |
| bool | $usesUniqueIds | Indicates if the model uses unique ids. |
from HasUniqueIds |
| $hidden | The attributes that should be hidden for serialization. |
from HidesAttributes | |
| protected array<int, string> | $visible | The attributes that should be visible in serialization. |
from HidesAttributes |
| protected array<int, string> | $fillable | The attributes that are mass assignable. |
from GuardsAttributes |
| protected string[] | $guarded | The attributes that aren't mass assignable. |
|
| static protected array<class-string, list<string>> | $guardableColumns | The actual columns that exist on the database and can be guarded. |
from GuardsAttributes |
| static protected array<class-string, array{guarded: null|array<int, string>, propertyDefault: array<int, string>}> | $guardConfigurations | The resolved guard configuration for each model class. |
from GuardsAttributes |
| static protected TCollection>> | $resolvedCollectionClasses | The resolved collection class names by model. |
from HasCollection |
| protected UnitEnum|string|null | $connection | The connection name for the model. |
from Model |
| protected string|null | $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 primary key ID. |
from Model |
| bool | $incrementing | Indicates if the IDs are auto-incrementing. |
|
| protected array<int, string> | $with | The relations to eager load on every query. |
from Model |
| protected array<int, string> | $withCount | The relationship counts that should be eager loaded on every query. |
from Model |
| bool | $preventsLazyLoading | Indicates whether lazy loading will be prevented on this model. |
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 object's lifecycle. |
from Model |
| protected bool | $escapeWhenCastingToString | Indicates that the object's string representation should be escaped when __toString is invoked. |
from Model |
| protected bool | $modelClassAttributesInitialized | Indicates whether class attribute metadata has initialized this model. |
from Model |
| static protected ConnectionResolverInterface|null | $resolver | The connection resolver instance. |
from Model |
| static protected Dispatcher|null | $dispatcher | The event dispatcher instance. |
from Model |
| static protected array<class-string<self>, int> | $booting | The coroutine currently booting each model. |
from Model |
| static protected array<class-string<self>, bool> | $booted | The array of booted models. |
from Model |
| static protected Closure>> | $bootedCallbacks | The callbacks that should be executed after the model has booted. |
from Model |
| static protected array<class-string<self>, array<int, string>> | $traitInitializers | The array of trait initializers that will be called on each new instance. |
from Model |
| static protected array<class-string<self>, array<int|Closure|Scope>> | $globalScopes | The array of global scopes on the model. |
from Model |
| static protected bool | $modelsShouldPreventLazyLoading | Indicates whether lazy loading should be restricted on all models. |
from Model |
| static protected bool | $modelsShouldAutomaticallyEagerLoadRelationships | Indicates whether relations should be automatically loaded on all models when they are accessed. |
from Model |
| static protected null|LazyLoadingViolationException): mixed | $lazyLoadingViolationCallback | The callback that is responsible for handling lazy loading violations. |
from Model |
| static protected bool | $modelsShouldPreventSilentlyDiscardingAttributes | Indicates if an exception should be thrown instead of silently discarding non-fillable attributes. |
from Model |
| static protected null|MassAssignmentException): mixed | $discardedAttributeViolationCallback | The callback that is responsible for handling discarded attribute violations. |
from Model |
| static protected bool | $modelsShouldPreventAccessingMissingAttributes | Indicates if an exception should be thrown when trying to access a missing attribute on a retrieved model. |
from Model |
| static protected null|MissingAttributeException): mixed | $missingAttributeViolationCallback | The callback that is responsible for handling missing attribute violations. |
from Model |
| static protected bool | $reportRouteModelBindingExceptions | Indicates if invalid value exceptions during implicit route model binding should be reported. |
from Model |
| static protected Builder<mixed>> | $builder | The Eloquent query builder class to use for the model. |
from Model |
| static protected Collection<mixed, mixed>> | $collectionClass | The Eloquent collection class to use for the model. |
from Model |
| static protected Builder<static>>|false> | $resolvedBuilderClasses | Cache of resolved custom builder classes per model. |
from Model |
| static protected array<string, null|object> | $classAttributes | Cache of resolved class attributes. |
from Model |
| static protected array<string, bool> | $classDeclaredAttributes | Cache of whether each class directly declares each class attribute. |
from Model |
| static protected array<string, null|class-string> | $classPropertyDeclarers | Cache of the nearest class declaring each property. |
from Model |
| static protected array<string, bool> | $scopeMethodAttributes | Cache of whether methods are attributed local scopes. |
from Model |
| static protected array<string, bool> | $legacyScopeMethods | Cache of whether methods are callable legacy local scopes. |
from Model |
| static protected array<class-string<self>, bool> | $isSoftDeletable | Cache of soft deletable models. |
from Model |
| static protected array<class-string<self>, bool> | $isPrunable | Cache of prunable models. |
from Model |
| static protected array<class-string<self>, bool> | $isMassPrunable | Cache of mass prunable models. |
from Model |
| Model|null | $pivotParent | The parent model of the relationship. |
from AsPivot |
| Model|null | $pivotRelated | The related model of the relationship. |
from AsPivot |
| protected string | $foreignKey | The name of the foreign key column. |
from AsPivot |
| protected string | $relatedKey | The name of the "other key" column. |
from AsPivot |
| protected null|list<array{string, array<int, mixed>}> | $pivotConstraints | The relation-owned predicates that identify this pivot row. |
from AsPivot |
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.
Determine whether an attribute exists on the model.
Either throw a missing attribute exception or return null depending on Eloquent's configuration.
Get an attribute from the $attributes array.
Determine if the given key is a relationship method on the model.
Get a relationship value from a method.
Determine if a get mutator exists for an attribute.
Determine if a "Attribute" return type marked mutator exists for an attribute.
Determine if a "Attribute" return type marked get mutator exists for an attribute.
Determine if any get mutator exists for an attribute.
Get the value of an attribute using its mutator.
Get the value of an "Attribute" return type marked attribute using its mutator.
Get the value of an attribute using its mutator for array conversion.
Merge new casts with existing casts on the model.
Ensure that the given casts are strings.
Cast an attribute to a native PHP type.
Cast the given attribute using a custom cast class.
Cast the given attribute to an enum.
Increment or decrement the given attribute using the custom cast class.
Serialize the given attribute using the custom cast class.
Compare two values for the given attribute using the custom cast class.
Determine if the cast type is a custom date time cast.
Determine if the cast type is an immutable custom date time cast.
Ensure the decimal cast has a valid scale.
Set a given attribute on the model.
Determine if a set mutator exists for an attribute.
Determine if an "Attribute" return type marked set mutator exists for an attribute.
Set the value of an attribute using its mutator.
Set the value of a "Attribute" return type marked attribute using its mutator.
Determine if the given attribute is a date or date castable.
Set a given JSON attribute on the model.
Set the value of a class castable attribute.
Set the value of an enum castable attribute.
Get an enum case instance from a given class and value.
Get the storable value from the given enum.
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.
Get the JSON casting flags for the given attribute.
Encode the given value as JSON.
Decode the given JSON back into an array or object.
Cast the given attribute to an encrypted string.
Set the encrypter instance that will be used to encrypt attributes.
Get the current encrypter being used by the model.
Cast the given attribute to a hashed string.
Return a timestamp as DateTime object with time set to 00:00:00.
Determine if the given value is a standard date format.
Set the date format used by the model.
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 Date / DateTime custom-castable for inbound manipulation.
Determine whether a value is JSON castable for inbound manipulation.
Determine whether a value is an encrypted castable for inbound manipulation.
Determine if the given key is cast using a custom class.
Determine if the given key is cast using an enum.
Determine if the key is deviable using a custom class.
Determine if the key is serializable using a custom class.
Determine if the key is comparable using a custom class.
Resolve the custom caster class for a given key.
Parse the given caster class, removing any arguments.
Merge the cast class and attribute cast attributes back into the model.
Merge the cast class and attribute cast attribute back into the model.
Merge the cast class attributes back into the model.
Merge the cast class attribute back into the model.
Merge the cast class attributes back into the model.
Merge the cast class attribute back into the model.
Normalize the response from a custom class caster.
Get all of the current attributes on the model for an insert operation.
Prepare binary-cast attributes for database binding.
Set the array of model attributes. No checking is done.
Get the model's original attribute values.
Get the model's original attribute values.
Get the model's raw original attribute values.
Sync a single original attribute with its current value.
Sync multiple original attribute with their current values.
Determine if the model or any of the given attribute(s) have been modified.
Determine if the model or all the given attribute(s) have remained the same.
Discard attribute changes and reset the attributes to their original state.
Determine if the model or any of the given attribute(s) were changed when the model was last saved.
Determine if any of the given attributes were changed when the model was last saved.
Get the attributes that have been changed since the last sync for an update operation.
Get the attributes that were changed when the model was last saved.
Get the attributes that were previously original before the model was last saved.
Determine if the new and old values for a given key are equivalent.
Transform a raw model value using mutators, casts, etc.
Append attributes to query when building a query.
Set the accessors to append to model arrays.
Merge new appended attributes with existing appended attributes on the model.
Return whether the accessor attribute has been appended.
Extract and cache all the mutated attributes of a class.
Get all of the attribute mutator methods.
Get all of the "Attribute" return typed attribute mutator methods.
Resolve the observe class names from the attributes.
Register a single observer with the model.
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 retrieved model event with the dispatcher.
Register a saving model event with the dispatcher.
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 replicating model event with the dispatcher.
Register a deleting model event with the dispatcher.
Register a deleted model event with the dispatcher.
Execute a callback without firing any model events for any model type.
Determine if model events are currently disabled for this coroutine.
Boot the has global scopes trait for a model.
Resolve the global scope class names from the attributes.
Register a new global scope on the model.
Register multiple global scopes on the model.
Get all of the global scopes that are currently registered.
Get the dynamic relation resolver if defined or inherited, or return null.
Determine if a relationship autoloader callback has been defined.
Define an automatic relationship autoloader callback for this model and its relations.
Attempt to autoload the given relationship using the autoload callback.
Invoke the relationship autoloader callback for the given relationships.
Propagate the relationship autoloader callback to the given related models.
Define a one-to-one relationship.
Instantiate a new HasOne relationship.
Define a has-one-through relationship.
Instantiate a new HasOneThrough 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.
Create a pending has-many-through or has-one-through relationship.
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 MorphToMany relationship.
Define a polymorphic, inverse many-to-many relationship.
Get the relationship name of the belongsToMany relationship.
Get the joining table name for a many-to-many relation.
Get this model's half of the intermediate table name for belongsToMany relationships.
Determine if the model touches a given relation.
Get the polymorphic relationship columns.
Create a new model instance for a related model.
Create a new model instance for a related "through" model.
Set the given relationship on the model.
Set the entire relations array on the model.
Enable relationship autoloading for this model.
Duplicate the instance and unset all the loaded relations.
Duplicate the instance and unset the given loaded relations.
Unset all the loaded relations for the instance.
Set the relationships that are touched on save.
Update the model's update timestamp.
Update the model's update timestamp without raising any events.
Set the value of the "created at" attribute.
Set the value of the "updated at" attribute.
Get the fully-qualified "created at" column.
Get the fully-qualified "updated at" column.
Disable timestamps for the current class during the given callback scope.
Disable timestamps for the given model classes during the given callback scope.
Determine if the given model is ignoring timestamps / touches.
Set the hidden attributes for the model.
Merge new hidden attributes with existing hidden attributes on the model.
Set the visible attributes for the model.
Merge new visible attributes with existing visible attributes on the model.
Make the given, typically hidden, attributes visible.
Make the given, typically hidden, attributes visible if the given truth test passes.
Make the given, typically visible, attributes hidden.
Make the given, typically visible, attributes hidden if the given truth test passes.
Resolve the nearest guard configuration for the model class.
Resolve guard configuration declared by traits at one class level.
Set the fillable attributes for the model.
Merge new fillable attributes with existing fillable attributes on the model.
Set the guarded attributes for the model.
Merge new guarded attributes with existing guarded attributes on the model.
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.
Prevent a method from being called multiple times on the same object within the same call stack.
Remove an entry from the recursion cache for an object.
Get the stack of methods being called recursively for the current object.
Get the current recursion cache being used by the model.
Set a value in the recursion cache for the given object and method.
Create a new resource object for the given resource.
Guess the resource class name for the model.
Get the resource class from the UseResource attribute.
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Create a new Eloquent Collection instance.
Resolve the collection class name from the CollectedBy attribute.
Clear the list of booted models so they will be re-booted.
Disables relationship model touching for the current class during given callback scope.
Disables relationship model touching for the given model classes during given callback scope.
Determine if the given model is ignoring touches.
Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.
Prevent model relationships from being lazy loaded.
Determine if model relationships should be automatically eager loaded when accessed.
Register a callback that is responsible for handling lazy loading violations.
Prevent non-fillable attributes from being silently discarded.
Register a callback that is responsible for handling discarded attribute violations.
Prevent accessing missing attributes on retrieved models.
Register a callback that is responsible for handling missing attribute violations.
Report invalid value exceptions during implicit route model binding.
Execute a callback without broadcasting any model events for all model types.
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 relationships on the polymorphic relation of a model.
Eager load relations on the model if they are not already eager loaded.
Eager load relation's column aggregations on the model.
Eager load relation max column values on the model.
Eager load relation min column values on the model.
Eager load relation's column summations on the model.
Eager load relation average column values on the model.
Eager load related model existence values on the model.
Eager load relationship column aggregation on the polymorphic relation of a model.
Eager load relationship counts on the polymorphic relation of a model.
Eager load relationship max column values on the polymorphic relation of a model.
Eager load relationship min column values on the polymorphic relation of a model.
Eager load relationship column summations on the polymorphic relation of a model.
Eager load relationship average column values on the polymorphic relation of a model.
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.
Update the model in the database.
Update the model in the database within a transaction.
Update the model in the database without raising any events.
Increment a column's value by a given amount without raising any events.
Decrement a column's value by a given amount without raising any events.
Increment each given column's value by the given amounts.
Decrement each given column's value by the given amounts.
Increment each given column's value by the given amounts without raising any events.
Decrement each given column's value by the given amounts without raising any events.
Run the incrementEach or decrementEach method on the model.
Save the model and all of its relationships without raising any events to the parent model.
Save the model to the database without raising any events.
Save the model to the database, ignoring specific unique constraint conflicts.
Save the model to the database within a transaction.
Perform any actions that are necessary after the model is saved.
Perform a model insert operation, ignoring specific unique constraint conflicts.
Insert the given attributes and set the ID on the model.
Delete the model from the database without raising any events.
Force a hard destroy on a soft deleted model.
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.
Resolve the custom Eloquent builder class from the model attributes.
Create a new pivot model instance.
Apply the given named scope if possible.
Determine if the given method has a scope attribute.
Determine if the given method is a callable legacy local scope.
Convert the model instance to pretty print formatted JSON.
Reload a fresh model instance from the database.
Reload the current model instance with fresh attributes from the database while locking it for updating.
Clone the model into a new, non-existing instance without raising any events.
Set the connection associated with the model.
Resolve a connection instance.
Get the connection resolver instance.
Resolve an attribute from the model class or its parents.
Determine whether a class directly declares an attribute.
Resolve the nearest class that declares a property.
Retrieve the model for a bound value.
Retrieve the model for a bound value.
Retrieve the child model for a bound value.
Retrieve the child model for a bound value.
Retrieve the child model query for a bound value.
Retrieve the child route model binding relationship name for the given child type.
Retrieve the model for a bound value.
Determine if the given value could address a row in an integer key column.
Throw an exception for the given invalid route key.
Determine if relationships are being automatically eager loaded when accessed.
Determine if discarding guarded attribute fills is disabled.
Determine if accessing missing attributes is disabled.
Determine if invalid value exceptions during implicit route model binding should be reported.
Get the broadcast channel route definition that is associated with the given entity.
Get the broadcast channel name that is associated with the given entity.
Handle dynamic method calls into the model.
Handle dynamic static method calls into the model.
Indicate that the object's string representation should be escaped when __toString is invoked.
Create a new pivot model instance.
Create a new pivot model from raw values returned from a query.
Apply the relation-owned predicates to a pivot identity query.
Set the key names for the pivot model instance.
Set the relation-owned predicates for the pivot model.
Determine if the pivot model or given attributes has timestamp attributes.
Get a new query to restore multiple models by their queueable IDs.
Details
in
HasAttributes at line 213
protected void
initializeHasAttributes()
Initialize the trait.
in
HasAttributes at line 242
array
attributesToArray()
Convert the model's attributes to an array.
in
HasAttributes at line 280
protected array
addDateAttributesToArray(array $attributes)
Add the date attributes to the attributes array.
in
HasAttributes at line 302
protected array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)
Add the mutated attributes to the attributes array.
in
HasAttributes at line 331
protected array
addCastAttributesToArray(array $attributes, array $mutatedAttributes)
Add the casted attributes to the attributes array.
in
HasAttributes at line 385
protected array
getArrayableAttributes()
Get an attribute array of all arrayable attributes.
in
HasAttributes at line 393
protected array
getArrayableAppends()
Get all of the appendable values that are arrayable.
in
HasAttributes at line 407
array
relationsToArray()
Get the model's relationships in array form.
in
HasAttributes at line 449
protected array
getArrayableRelations()
Get an attribute array of all arrayable relations.
in
HasAttributes at line 457
protected array
getArrayableItems(array $values)
Get an attribute array of all arrayable values.
in
HasAttributes at line 473
bool
hasAttribute(string $key)
Determine whether an attribute exists on the model.
in
HasAttributes at line 489
mixed
getAttribute(string $key)
Get an attribute from the model.
in
HasAttributes at line 519
protected mixed
throwMissingAttributeExceptionIfApplicable(string $key)
Either throw a missing attribute exception or return null depending on Eloquent's configuration.
in
HasAttributes at line 540
mixed
getAttributeValue(string $key)
Get a plain attribute (not a relationship).
in
HasAttributes at line 548
protected mixed
getAttributeFromArray(string $key)
Get an attribute from the $attributes array.
in
HasAttributes at line 558
mixed
getRelationValue(string $key)
Get a relationship.
in
HasAttributes at line 588
bool
isRelation(string $key)
Determine if the given key is a relationship method on the model.
in
HasAttributes at line 603
protected mixed
handleLazyLoadingViolation(string $key)
Handle a lazy loading violation.
in
HasAttributes at line 628
protected mixed
getRelationshipFromMethod(string $method)
Get a relationship value from a method.
in
HasAttributes at line 656
bool
hasGetMutator(string $key)
Determine if a get mutator exists for an attribute.
in
HasAttributes at line 664
bool
hasAttributeMutator(string $key)
Determine if a "Attribute" return type marked mutator exists for an attribute.
in
HasAttributes at line 684
bool
hasAttributeGetMutator(string $key)
Determine if a "Attribute" return type marked get mutator exists for an attribute.
in
HasAttributes at line 700
bool
hasAnyGetMutator(string $key)
Determine if any get mutator exists for an attribute.
in
HasAttributes at line 708
protected mixed
mutateAttribute(string $key, mixed $value)
Get the value of an attribute using its mutator.
in
HasAttributes at line 718
protected mixed
mutateAttributeMarkedAttribute(string $key, mixed $value)
Get the value of an "Attribute" return type marked attribute using its mutator.
in
HasAttributes at line 744
protected mixed
mutateAttributeForArray(string $key, mixed $value)
Get the value of an attribute using its mutator for array conversion.
in
HasAttributes at line 765
HasAttributes
mergeCasts(array $casts)
Merge new casts with existing casts on the model.
in
HasAttributes at line 779
protected void
flushCastCaches()
Flush the per-instance cast metadata caches.
in
HasAttributes at line 790
protected array
ensureCastsAreStringValues(array $casts)
Ensure that the given casts are strings.
in
HasAttributes at line 822
protected mixed
castAttribute(string $key, mixed $value)
Cast an attribute to a native PHP type.
in
HasAttributes at line 890
protected mixed
getClassCastableAttributeValue(string $key, mixed $value)
Cast the given attribute using a custom cast class.
in
HasAttributes at line 917
protected mixed
getEnumCastableAttributeValue(string $key, mixed $value)
Cast the given attribute to an enum.
in
HasAttributes at line 935
protected string
getCastType(string $key)
Get the type of cast for a model attribute.
in
HasAttributes at line 969
protected mixed
deviateClassCastableAttribute(string $method, string $key, mixed $value)
Increment or decrement the given attribute using the custom cast class.
in
HasAttributes at line 982
protected mixed
serializeClassCastableAttribute(string $key, mixed $value)
Serialize the given attribute using the custom cast class.
in
HasAttributes at line 995
protected bool
compareClassCastableAttribute(string $key, mixed $original, mixed $value)
Compare two values for the given attribute using the custom cast class.
in
HasAttributes at line 1008
protected bool
isCustomDateTimeCast(string $cast)
Determine if the cast type is a custom date time cast.
in
HasAttributes at line 1017
protected bool
isImmutableCustomDateTimeCast(string $cast)
Determine if the cast type is an immutable custom date time cast.
in
HasAttributes at line 1026
protected bool
isDecimalCast(string $cast)
Determine if the cast type is a decimal cast.
in
HasAttributes at line 1034
protected void
ensureValidDecimalScale(string $cast, string $attribute)
Ensure the decimal cast has a valid scale.
in
HasAttributes at line 1048
mixed
setAttribute(string|int $key, mixed $value)
Set a given attribute on the model.
in
HasAttributes at line 1117
bool
hasSetMutator(string $key)
Determine if a set mutator exists for an attribute.
in
HasAttributes at line 1125
bool
hasAttributeSetMutator(string $key)
Determine if an "Attribute" return type marked set mutator exists for an attribute.
in
HasAttributes at line 1148
protected mixed
setMutatedAttributeValue(string $key, mixed $value)
Set the value of an attribute using its mutator.
in
HasAttributes at line 1158
protected mixed
setAttributeMarkedMutatedAttributeValue(string $key, mixed $value)
Set the value of a "Attribute" return type marked attribute using its mutator.
in
HasAttributes at line 1188
protected bool
isDateAttribute(string $key)
Determine if the given attribute is a date or date castable.
in
HasAttributes at line 1197
HasAttributes
fillJsonAttribute(string $key, mixed $value)
Set a given JSON attribute on the model.
in
HasAttributes at line 1221
protected void
setClassCastableAttribute(string $key, mixed $value)
Set the value of a class castable attribute.
in
HasAttributes at line 1249
protected void
setEnumCastableAttribute(string $key, mixed $value)
Set the value of an enum castable attribute.
in
HasAttributes at line 1270
protected mixed
getEnumCaseFromValue(string $enumClass, string|int $value)
Get an enum case instance from a given class and value.
in
HasAttributes at line 1284
protected string|int
getStorableEnumValue(string $expectedEnum, mixed $value)
Get the storable value from the given enum.
in
HasAttributes at line 1296
protected array
getArrayAttributeWithValue(string $path, string $key, mixed $value)
Get an array attribute with the given key and value set.
in
HasAttributes at line 1306
protected array
getArrayAttributeByKey(string $key)
Get an array attribute or return an empty array if it is not set.
in
HasAttributes at line 1324
protected string
castAttributeAsJson(string $key, mixed $value)
Cast the given attribute to JSON.
in
HasAttributes at line 1342
protected int
getJsonCastFlags(string $key)
Get the JSON casting flags for the given attribute.
in
HasAttributes at line 1356
protected string|false
asJson(mixed $value, int $flags = 0)
Encode the given value as JSON.
in
HasAttributes at line 1364
mixed
fromJson(string|null $value, bool $asObject = false)
Decode the given JSON back into an array or object.
in
HasAttributes at line 1376
mixed
fromEncryptedString(string $value)
Decrypt the given encrypted string.
in
HasAttributes at line 1384
protected string
castAttributeAsEncryptedString(string $key, mixed $value)
Cast the given attribute to an encrypted string.
in
HasAttributes at line 1395
static void
encryptUsing(Encrypter|null $encrypter)
Set the encrypter instance that will be used to encrypt attributes.
Boot-only. The encrypter persists in a static property for the worker lifetime and is used by every encrypted attribute across all coroutines.
in
HasAttributes at line 1403
static Encrypter
currentEncrypter()
Get the current encrypter being used by the model.
in
HasAttributes at line 1413
protected string|null
castAttributeAsHashedString(string $key, mixed $value)
Cast the given attribute to a hashed string.
in
HasAttributes at line 1434
float
fromFloat(mixed $value)
Decode the given float.
in
HasAttributes at line 1454
protected string
asDecimal(float|string $value, int $decimals)
Return a decimal as string.
in
HasAttributes at line 1466
protected CarbonInterface
asDate(mixed $value)
Return a timestamp as DateTime object with time set to 00:00:00.
in
HasAttributes at line 1474
protected CarbonInterface
asDateTime(mixed $value)
Return a timestamp as DateTime object.
in
HasAttributes at line 1525
protected bool
isStandardDateFormat(string $value)
Determine if the given value is a standard date format.
in
HasAttributes at line 1533
string|null
fromDateTime(mixed $value)
Convert a DateTime to a storable string.
in
HasAttributes at line 1543
protected int
asTimestamp(mixed $value)
Return a timestamp as unix timestamp.
in
HasAttributes at line 1551
protected string
serializeDate(DateTimeInterface $date)
Prepare a date for array / JSON serialization.
in
HasAttributes at line 1563
array
getDates()
Get the attributes that should be converted to dates.
in
HasAttributes at line 1574
string
getDateFormat()
Get the format for database stored dates.
in
HasAttributes at line 1582
HasAttributes
setDateFormat(string $format)
Set the date format used by the model.
in
HasAttributes at line 1592
bool
hasCast(string $key, array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
in
HasAttributes at line 1606
array
getCasts()
Get the attributes that should be cast.
in
HasAttributes at line 1623
protected array
casts()
Get the attributes that should be cast.
in
HasAttributes at line 1631
protected bool
isDateCastable(string $key)
Determine whether a value is Date / DateTime castable for inbound manipulation.
in
HasAttributes at line 1639
protected bool
isDateCastableWithCustomFormat(string $key)
Determine whether a value is Date / DateTime custom-castable for inbound manipulation.
in
HasAttributes at line 1647
protected bool
isJsonCastable(string $key)
Determine whether a value is JSON castable for inbound manipulation.
in
HasAttributes at line 1655
protected bool
isEncryptedCastable(string $key)
Determine whether a value is an encrypted castable for inbound manipulation.
in
HasAttributes at line 1665
protected bool
isClassCastable(string $key)
Determine if the given key is cast using a custom class.
in
HasAttributes at line 1693
protected bool
isEnumCastable(string $key)
Determine if the given key is cast using an enum.
in
HasAttributes at line 1723
protected bool
isClassDeviable(string $key)
Determine if the key is deviable using a custom class.
in
HasAttributes at line 1743
protected bool
isClassSerializable(string $key)
Determine if the key is serializable using a custom class.
in
HasAttributes at line 1753
protected bool
isClassComparable(string $key)
Determine if the key is comparable using a custom class.
in
HasAttributes at line 1763
protected mixed
resolveCasterClass(string $key)
Resolve the custom caster class for a given key.
in
HasAttributes at line 1799
static void
flushCasterCache()
Flush the caster cache for the model.
Boot or tests only. Clears the worker-wide caster instance cache shared by every coroutine; next attribute access rebuilds the casters.
in
HasAttributes at line 1807
protected string
parseCasterClass(string $class)
Parse the given caster class, removing any arguments.
in
HasAttributes at line 1817
protected void
mergeAttributesFromCachedCasts()
Merge the cast class and attribute cast attributes back into the model.
in
HasAttributes at line 1826
protected void
mergeAttributeFromCachedCasts(string $key)
Merge the cast class and attribute cast attribute back into the model.
in
HasAttributes at line 1835
protected void
mergeAttributesFromClassCasts()
Merge the cast class attributes back into the model.
in
HasAttributes at line 1845
protected void
mergeAttributeFromClassCasts(string $key)
Merge the cast class attribute back into the model.
in
HasAttributes at line 1865
protected void
mergeAttributesFromAttributeCasts()
Merge the cast class attributes back into the model.
in
HasAttributes at line 1875
protected void
mergeAttributeFromAttributeCasts(string $key)
Merge the cast class attribute back into the model.
in
HasAttributes at line 1904
protected array
normalizeCastClassResponse(string $key, mixed $value)
Normalize the response from a custom class caster.
in
HasAttributes at line 1914
array
getAttributes()
Get all of the current attributes on the model.
in
HasAttributes at line 1924
protected array
getAttributesForInsert()
Get all of the current attributes on the model for an insert operation.
in
HasAttributes at line 1944
array
prepareBinaryAttributesForDatabase(array $attributes)
Prepare binary-cast attributes for database binding.
in
HasAttributes at line 1970
HasAttributes
setRawAttributes(array $attributes, bool $sync = false)
Set the array of model attributes. No checking is done.
in
HasAttributes at line 1989
mixed
getOriginal(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
in
HasAttributes at line 2002
protected mixed
getOriginalWithoutRewindingModel(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
in
HasAttributes at line 2021
mixed
getRawOriginal(string|null $key = null, mixed $default = null)
Get the model's raw original attribute values.
in
HasAttributes at line 2032
array
only(mixed $attributes)
Get a subset of the model's attributes.
in
HasAttributes at line 2048
array
except(mixed $attributes)
Get all attributes except the given ones.
in
HasAttributes at line 2066
HasAttributes
syncOriginal()
Sync the original attributes with the current.
in
HasAttributes at line 2076
HasAttributes
syncOriginalAttribute(string $attribute)
Sync a single original attribute with its current value.
in
HasAttributes at line 2086
HasAttributes
syncOriginalAttributes(array|string $attributes)
Sync multiple original attribute with their current values.
in
HasAttributes at line 2102
HasAttributes
syncChanges()
Sync the changed attributes.
in
HasAttributes at line 2125
bool
isDirty(array|string|null $attributes = null)
Determine if the model or any of the given attribute(s) have been modified.
in
HasAttributes at line 2138
bool
isClean(array|string|null $attributes = null)
Determine if the model or all the given attribute(s) have remained the same.
in
HasAttributes at line 2146
HasAttributes
discardChanges()
Discard attribute changes and reset the attributes to their original state.
in
HasAttributes at line 2161
bool
wasChanged(array|string|null $attributes = null)
Determine if the model or any of the given attribute(s) were changed when the model was last saved.
in
HasAttributes at line 2175
protected bool
hasChanges(array $changes, array|string|null $attributes = null)
Determine if any of the given attributes were changed when the model was last saved.
in
HasAttributes at line 2201
array
getDirty()
Get the attributes that have been changed since the last sync.
in
HasAttributes at line 2233
protected array
getDirtyForUpdate()
Get the attributes that have been changed since the last sync for an update operation.
in
HasAttributes at line 2243
array
getChanges()
Get the attributes that were changed when the model was last saved.
in
HasAttributes at line 2253
array
getPrevious()
Get the attributes that were previously original before the model was last saved.
in
HasAttributes at line 2261
bool
originalIsEquivalent(string $key)
Determine if the new and old values for a given key are equivalent.
in
HasAttributes at line 2352
protected mixed
transformModelValue(string $key, mixed $value)
Transform a raw model value using mutators, casts, etc.
in
HasAttributes at line 2394
HasAttributes
append(array|string $attributes)
Append attributes to query when building a query.
in
HasAttributes at line 2406
array
getAppends()
Get the accessors that are being appended to model arrays.
in
HasAttributes at line 2414
HasAttributes
setAppends(array $appends)
Set the accessors to append to model arrays.
in
HasAttributes at line 2426
HasAttributes
mergeAppends(array $appends)
Merge new appended attributes with existing appended attributes on the model.
in
HasAttributes at line 2440
bool
hasAppended(string $attribute)
Return whether the accessor attribute has been appended.
in
HasAttributes at line 2448
HasAttributes
withoutAppends()
Remove all appended properties from the model.
in
HasAttributes at line 2456
array
getMutatedAttributes()
Get the mutated attributes for a given instance.
in
HasAttributes at line 2468
static void
cacheMutatedAttributes(object|string $classOrInstance)
Extract and cache all the mutated attributes of a class.
in
HasAttributes at line 2487
static protected array
getMutatorMethods(mixed $class)
Get all of the attribute mutator methods.
in
HasAttributes at line 2497
static protected array
getAttributeMarkedMutatorMethods(mixed $class)
Get all of the "Attribute" return typed attribute mutator methods.
in
HasEvents at line 41
static void
bootHasEvents()
Boot the has event trait for a model.
in
HasEvents at line 57
static array
resolveObserveAttributes()
Resolve the observe class names from the attributes.
in
HasEvents at line 88
static void
observe(object|array|string $classes)
Register observers with the model.
Boot-only. Observer listeners are registered on the worker-wide event dispatcher and persist for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 104
protected void
registerObserver(object|string $class)
Register a single observer with the model.
in
HasEvents at line 144
array
getObservableEvents()
Get the observable event names.
in
HasEvents at line 162
HasEvents
setObservableEvents(array $observables)
Set the observable event names.
in
HasEvents at line 174
void
addObservableEvents(array|string $observables)
Add an observable event name.
in
HasEvents at line 187
void
removeObservableEvents(array|string $observables)
Remove an observable event name.
in
HasEvents at line 200
static protected void
registerModelEvent(string $event, mixed $callback)
Register a model event with the dispatcher.
in
HasEvents at line 212
protected mixed
fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
in
HasEvents at line 242
protected mixed
fireCustomModelEvent(string $event, string $method)
Fire a custom model event for the given event.
in
HasEvents at line 260
protected mixed
filterModelEventResults(mixed $result)
Filter the model event results.
in
HasEvents at line 278
static void
retrieved(mixed $callback)
Register a retrieved model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 292
static void
saving(mixed $callback)
Register a saving model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 306
static void
saved(mixed $callback)
Register a saved model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 320
static void
updating(mixed $callback)
Register an updating model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 334
static void
updated(mixed $callback)
Register an updated model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 348
static void
creating(mixed $callback)
Register a creating model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 362
static void
created(mixed $callback)
Register a created model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 376
static void
replicating(mixed $callback)
Register a replicating model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 390
static void
deleting(mixed $callback)
Register a deleting model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 404
static void
deleted(mixed $callback)
Register a deleted model event with the dispatcher.
Boot-only. Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.
in
HasEvents at line 415
static void
flushEventListeners()
Remove all the event listeners for the model.
Boot or tests only. Removes listeners from the worker-wide event dispatcher; concurrent coroutines lose model events mid-request.
in
HasEvents at line 437
array
dispatchesEvents()
Get the event map for the model.
in
HasEvents at line 448
static Dispatcher|null
getEventDispatcher()
Get the event dispatcher instance.
Returns a NullDispatcher when events are disabled (inside withoutEvents()) to ensure manual dispatch() calls are also suppressed, matching Laravel behavior.
in
HasEvents at line 463
static void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
Boot-only. The dispatcher persists in a static property for the worker lifetime and is used by every model event firing across all coroutines.
in
HasEvents at line 474
static void
unsetEventDispatcher()
Unset the event dispatcher for models.
Tests only. Clears the worker-wide event dispatcher shared by every coroutine; concurrent model operations will not fire events.
in
HasEvents at line 490
static mixed
withoutEvents(callable $callback)
Execute a callback without firing any model events for any model type.
Uses Context for coroutine-safe event disabling, ensuring concurrent requests don't interfere with each other's event handling.
in
HasEvents at line 505
static bool
eventsDisabled()
Determine if model events are currently disabled for this coroutine.
in
HasGlobalScopes at line 23
static void
bootHasGlobalScopes()
Boot the has global scopes trait for a model.
in
HasGlobalScopes at line 31
static array
resolveGlobalScopeAttributes()
Resolve the global scope class names from the attributes.
in
HasGlobalScopes at line 68
static mixed
addGlobalScope(Scope|Closure|string $scope, Scope|Closure|null $implementation = null)
Register a new global scope on the model.
Boot-only. The scope persists in a static property for the worker lifetime and applies to every query for this model class across all coroutines.
in
HasGlobalScopes at line 92
static void
addGlobalScopes(array $scopes)
Register multiple global scopes on the model.
Boot-only. Delegates to addGlobalScope() per entry; each scope persists in a static property for the worker lifetime.
in
HasGlobalScopes at line 106
static bool
hasGlobalScope(Scope|int|string $scope)
Determine if a model has a global scope.
in
HasGlobalScopes at line 116
static Scope|Closure|null
getGlobalScope(Scope|int|string $scope)
Get a global scope registered with the model.
in
HasGlobalScopes at line 128
static array
getAllGlobalScopes()
Get all of the global scopes that are currently registered.
in
HasGlobalScopes at line 140
static void
setAllGlobalScopes(array $scopes)
Set the current global scopes.
Boot or tests only. Replaces the worker-wide global scopes registry shared by every coroutine; per-request use changes scope behavior for every concurrent model query.
in
HasGlobalScopes at line 148
array
getGlobalScopes()
Get the global scopes for this class instance.
in
HasRelationships at line 70
void
initializeHasRelationships()
Initialize the HasRelationships trait.
in
HasRelationships at line 89
Closure|null
relationResolver(string $class, string $key)
Get the dynamic relation resolver if defined or inherited, or return null.
in
HasRelationships at line 109
static void
resolveRelationUsing(string $name, Closure $callback)
Define a dynamic relation resolver.
Boot-only. The resolver persists in a static property for the worker lifetime and runs on every relation resolution for this model class across all coroutines.
in
HasRelationships at line 120
bool
hasRelationAutoloadCallback()
Determine if a relationship autoloader callback has been defined.
in
HasRelationships at line 128
HasRelationships
autoloadRelationsUsing(Closure $callback, mixed $context = null)
Define an automatic relationship autoloader callback for this model and its relations.
in
HasRelationships at line 148
protected bool
attemptToAutoloadRelation(string $key)
Attempt to autoload the given relationship using the autoload callback.
in
HasRelationships at line 162
protected void
invokeRelationAutoloadCallbackFor(string $key, array $tuples)
Invoke the relationship autoloader callback for the given relationships.
in
HasRelationships at line 172
protected void
propagateRelationAutoloadCallbackToRelation(string $key, mixed $models)
Propagate the relationship autoloader callback to the given related models.
in
HasRelationships at line 201
HasOne
hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null)
Define a one-to-one relationship.
in
HasRelationships at line 222
protected HasOne
newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasOne relationship.
in
HasRelationships at line 237
HasOneThrough
hasOneThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null)
Define a has-one-through relationship.
in
HasRelationships at line 268
protected HasOneThrough
newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)
Instantiate a new HasOneThrough relationship.
in
HasRelationships at line 281
MorphOne
morphOne(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)
Define a polymorphic one-to-one relationship.
in
HasRelationships at line 302
protected MorphOne
newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphOne relationship.
in
HasRelationships at line 315
BelongsTo
belongsTo(string $related, string|null $foreignKey = null, string|null $ownerKey = null, string|null $relation = null)
Define an inverse one-to-one or many relationship.
in
HasRelationships at line 357
protected BelongsTo
newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)
Instantiate a new BelongsTo relationship.
in
HasRelationships at line 367
MorphTo
morphTo(string|null $name = null, string|null $type = null, string|null $id = null, string|null $ownerKey = null)
Define a polymorphic, inverse one-to-one or many relationship.
in
HasRelationships at line 393
protected MorphTo
morphEagerTo(string $name, string $type, string $id, string|null $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
in
HasRelationships at line 411
protected MorphTo
morphInstanceTo(string|int $target, string $name, string $type, string $id, string|null $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
in
HasRelationships at line 437
protected MorphTo
newMorphTo(Builder $query, Model $parent, string $foreignKey, string|null $ownerKey, string $type, string $relation)
Instantiate a new MorphTo relationship.
in
HasRelationships at line 445
static string
getActualClassNameForMorph(string|int $class)
Retrieve the actual class name for a given morph class.
in
HasRelationships at line 453
protected string
guessBelongsToRelation()
Guess the "belongs to" relationship name.
in
HasRelationships at line 477
PendingHasThroughRelationship
through(string|HasOneOrMany $relationship)
Create a pending has-many-through or has-one-through relationship.
in
HasRelationships at line 495
HasMany
hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null)
Define a one-to-many relationship.
in
HasRelationships at line 521
protected HasMany
newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasMany relationship.
in
HasRelationships at line 536
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.
in
HasRelationships at line 567
protected HasManyThrough
newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)
Instantiate a new HasManyThrough relationship.
in
HasRelationships at line 580
MorphMany
morphMany(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)
Define a polymorphic one-to-many relationship.
in
HasRelationships at line 604
protected MorphMany
newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphMany relationship.
in
HasRelationships at line 620
BelongsToMany
belongsToMany(string $related, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, string|null $relation = null)
Define a many-to-many relationship.
in
HasRelationships at line 679
protected BelongsToMany
newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null)
Instantiate a new BelongsToMany relationship.
in
HasRelationships at line 700
MorphToMany
morphToMany(string $related, string $name, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, string|null $relation = null, bool $inverse = false)
Define a polymorphic many-to-many relationship.
in
HasRelationships at line 757
protected MorphToMany
newMorphToMany(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null, bool $inverse = false)
Instantiate a new MorphToMany relationship.
in
HasRelationships at line 791
MorphToMany
morphedByMany(string $related, string $name, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, string|null $relation = null)
Define a polymorphic, inverse many-to-many relationship.
in
HasRelationships at line 824
protected string|null
guessBelongsToManyRelation()
Get the relationship name of the belongsToMany relationship.
in
HasRelationships at line 840
string
joiningTable(string $related, Model|null $instance = null)
Get the joining table name for a many-to-many relation.
in
HasRelationships at line 863
string
joiningTableSegment()
Get this model's half of the intermediate table name for belongsToMany relationships.
in
HasRelationships at line 871
bool
touches(string $relation)
Determine if the model touches a given relation.
in
HasRelationships at line 879
void
touchOwners()
Touch the owning relations of the model.
in
HasRelationships at line 901
protected array
getMorphs(string $name, string|null $type, string|null $id)
Get the polymorphic relationship columns.
in
HasRelationships at line 911
string
getMorphClass()
Get the class name for polymorphic relations.
in
HasRelationships at line 939
protected Model
newRelatedInstance(string $class)
Create a new model instance for a related model.
in
HasRelationships at line 956
protected Model
newRelatedThroughInstance(string $class)
Create a new model instance for a related "through" model.
in
HasRelationships at line 964
array
getRelations()
Get all the loaded relations for the instance.
in
HasRelationships at line 972
mixed
getRelation(string $relation)
Get a specified relationship.
in
HasRelationships at line 980
bool
relationLoaded(string $key)
Determine if the given relation is loaded.
in
HasRelationships at line 990
HasRelationships
setRelation(string $relation, mixed $value)
Set the given relationship on the model.
in
HasRelationships at line 1004
HasRelationships
unsetRelation(string $relation)
Unset a loaded relationship.
in
HasRelationships at line 1016
HasRelationships
setRelations(array $relations)
Set the entire relations array on the model.
in
HasRelationships at line 1028
HasRelationships
withRelationshipAutoloading()
Enable relationship autoloading for this model.
in
HasRelationships at line 1038
HasRelationships
withoutRelations()
Duplicate the instance and unset all the loaded relations.
in
HasRelationships at line 1048
HasRelationships
withoutRelation(array|string $relations)
Duplicate the instance and unset the given loaded relations.
in
HasRelationships at line 1064
HasRelationships
unsetRelations()
Unset all the loaded relations for the instance.
in
HasRelationships at line 1074
array
getTouchedRelations()
Get the relationships that are touched on save.
in
HasRelationships at line 1084
HasRelationships
setTouchedRelations(array $touches)
Set the relationships that are touched on save.
in
HasTimestamps at line 30
void
initializeHasTimestamps()
Initialize the HasTimestamps trait.
in
HasTimestamps at line 54
bool
touch(array|string|null $attribute = null)
Update the model's update timestamp.
in
HasTimestamps at line 78
bool
touchQuietly(array|string|null $attribute = null)
Update the model's update timestamp without raising any events.
in
HasTimestamps at line 88
HasTimestamps
updateTimestamps()
Update the creation and update timestamps.
in
HasTimestamps at line 112
HasTimestamps
setCreatedAt(mixed $value)
Set the value of the "created at" attribute.
in
HasTimestamps at line 124
HasTimestamps
setUpdatedAt(mixed $value)
Set the value of the "updated at" attribute.
in
HasTimestamps at line 134
CarbonInterface
freshTimestamp()
Get a fresh timestamp for the model.
in
HasTimestamps at line 142
string
freshTimestampString()
Get a fresh timestamp for the model.
in
HasTimestamps at line 150
bool
usesTimestamps()
Determine if the model uses timestamps.
in
HasTimestamps at line 158
string|null
getCreatedAtColumn()
Get the name of the "created at" column.
in
HasTimestamps at line 166
string|null
getUpdatedAtColumn()
Get the name of the "updated at" column.
in
HasTimestamps at line 174
string|null
getQualifiedCreatedAtColumn()
Get the fully-qualified "created at" column.
in
HasTimestamps at line 184
string|null
getQualifiedUpdatedAtColumn()
Get the fully-qualified "updated at" column.
in
HasTimestamps at line 199
static mixed
withoutTimestamps(callable $callback)
Disable timestamps for the current class during the given callback scope.
in
HasTimestamps at line 213
static mixed
withoutTimestampsOn(array $models, callable $callback)
Disable timestamps for the given model classes during the given callback scope.
in
HasTimestamps at line 231
static bool
isIgnoringTimestamps(string|null $class = null)
Determine if the given model is ignoring timestamps / touches.
in
HasUniqueIds at line 17
bool
usesUniqueIds()
Determine if the model uses unique ids.
in
HasUniqueIds at line 25
void
setUniqueIds()
Generate unique keys for the model.
in
HasUniqueIds at line 37
string|null
newUniqueId()
Generate a new key for the model.
in
HasUniqueIds at line 47
array
uniqueIds()
Get the columns that should receive a unique identifier.
in
HidesAttributes at line 31
void
initializeHidesAttributes()
Initialize the HidesAttributes trait.
in
HidesAttributes at line 47
array
getHidden()
Get the hidden attributes for the model.
in
HidesAttributes at line 58
HidesAttributes
setHidden(array $hidden)
Set the hidden attributes for the model.
in
HidesAttributes at line 71
HidesAttributes
mergeHidden(array $hidden)
Merge new hidden attributes with existing hidden attributes on the model.
in
HidesAttributes at line 87
array
getVisible()
Get the visible attributes for the model.
in
HidesAttributes at line 98
HidesAttributes
setVisible(array $visible)
Set the visible attributes for the model.
in
HidesAttributes at line 111
HidesAttributes
mergeVisible(array $visible)
Merge new visible attributes with existing visible attributes on the model.
in
HidesAttributes at line 128
HidesAttributes
makeVisible(array|string|null $attributes)
Make the given, typically hidden, attributes visible.
in
HidesAttributes at line 147
HidesAttributes
makeVisibleIf(bool|Closure $condition, array|string|null $attributes)
Make the given, typically hidden, attributes visible if the given truth test passes.
in
HidesAttributes at line 158
HidesAttributes
makeHidden(array|string|null $attributes)
Make the given, typically visible, attributes hidden.
in
HidesAttributes at line 174
HidesAttributes
makeHiddenIf(bool|Closure $condition, array|string|null $attributes)
Make the given, typically visible, attributes hidden if the given truth test passes.
in
GuardsAttributes at line 48
void
initializeGuardsAttributes()
Initialize the GuardsAttributes trait.
in
GuardsAttributes at line 72
static protected array
guardConfiguration()
Resolve the nearest guard configuration for the model class.
in
GuardsAttributes at line 126
static protected array|null
guardConfigurationFromTraits(array $traits)
Resolve guard configuration declared by traits at one class level.
in
GuardsAttributes at line 149
array
getFillable()
Get the fillable attributes for the model.
in
GuardsAttributes at line 159
GuardsAttributes
fillable(array $fillable)
Set the fillable attributes for the model.
in
GuardsAttributes at line 171
GuardsAttributes
mergeFillable(array $fillable)
Merge new fillable attributes with existing fillable attributes on the model.
in
GuardsAttributes at line 187
array
getGuarded()
Get the guarded attributes for the model.
in
GuardsAttributes at line 199
GuardsAttributes
guard(array $guarded)
Set the guarded attributes for the model.
in
GuardsAttributes at line 211
GuardsAttributes
mergeGuarded(array $guarded)
Merge new guarded attributes with existing guarded attributes on the model.
in
GuardsAttributes at line 223
static void
unguard(bool $state = true)
Disable all mass assignable restrictions.
Uses Context for coroutine-safe state management.
in
GuardsAttributes at line 231
static void
reguard()
Enable the mass assignment restrictions.
in
GuardsAttributes at line 239
static bool
isUnguarded()
Determine if the current state is "unguarded".
in
GuardsAttributes at line 255
static mixed
unguarded(callable $callback)
Run the given callable while being unguarded.
Uses Context for coroutine-safe state management, ensuring concurrent requests don't interfere with each other's guarding state.
in
GuardsAttributes at line 274
bool
isFillable(string $key)
Determine if the given attribute may be mass assigned.
in
GuardsAttributes at line 302
bool
isGuarded(string $key)
Determine if the given key is guarded.
in
GuardsAttributes at line 316
protected bool
isGuardableColumn(string $key)
Determine if the given column is a valid, guardable column.
in
GuardsAttributes at line 340
bool
totallyGuarded()
Determine if the model is totally guarded.
in
GuardsAttributes at line 351
protected array
fillableFromArray(array $attributes)
Get the fillable attributes of a given array.
in
PreventsCircularRecursion at line 22
protected mixed
withoutRecursion(callable $callback, mixed $default = null)
Prevent a method from being called multiple times on the same object within the same call stack.
in
PreventsCircularRecursion at line 52
static protected void
clearRecursiveCallValue(object $object, string $hash)
Remove an entry from the recursion cache for an object.
in
PreventsCircularRecursion at line 66
static protected array
getRecursiveCallStack(object $object)
Get the stack of methods being called recursively for the current object.
in
PreventsCircularRecursion at line 78
static protected WeakMap
getRecursionCache()
Get the current recursion cache being used by the model.
in
PreventsCircularRecursion at line 86
static protected mixed
setRecursiveCallValue(object $object, string $hash, mixed $value)
Set a value in the recursion cache for the given object and method.
in
TransformsToResource at line 23
JsonResource
toResource(string|null $resourceClass = null)
Create a new resource object for the given resource.
in
TransformsToResource at line 37
protected JsonResource
guessResource()
Guess the resource class for the model.
in
TransformsToResource at line 59
static array
guessResourceName()
Guess the resource class name for the model.
in
TransformsToResource at line 89
protected string|null
resolveResourceFromAttribute(string $class)
Get the resource class from the UseResource attribute.
in
ForwardsCalls at line 22
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
in
ForwardsCalls at line 52
protected mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object, returning $this if the forwarded call returned itself.
in
ForwardsCalls at line 66
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
in
HasCollection at line 28
Collection
newCollection(array $models = [])
Create a new Eloquent Collection instance.
in
HasCollection at line 48
string|null
resolveCollectionFromAttribute()
Resolve the collection class name from the CollectedBy attribute.
in
Model at line 359
__construct(array $attributes = [])
Create a new Eloquent model instance.
in
Model at line 380
protected void
bootIfNotBooted()
Check if the model needs to be booted and if so, do it.
in
Model at line 449
static protected void
booting()
Perform any actions required before the model boots.
in
Model at line 456
static protected void
boot()
Bootstrap the model and its traits.
in
Model at line 464
static protected void
bootTraits()
Boot all of the bootable traits on the model.
in
Model at line 499
protected void
initializeTraits()
Initialize any initializable traits on the model.
in
Model at line 509
void
initializeModelAttributes()
Initialize the model attributes from class attributes.
in
Model at line 546
static protected void
booted()
Perform any actions required after the model boots.
in
Model at line 553
static protected void
whenBooted(Closure $callback)
Register a closure to be executed after the model has booted.
in
Model at line 567
static void
clearBootedModels()
Clear the list of booted models so they will be re-booted.
Boot or tests only. Clears worker-wide boot state, boot callbacks, and global scopes; concurrent coroutines mid-query may observe inconsistent model state.
in
Model at line 584
static void
withoutTouching(callable $callback)
Disables relationship model touching for the current class during given callback scope.
in
Model at line 594
static void
withoutTouchingOn(array $models, callable $callback)
Disables relationship model touching for the given model classes during given callback scope.
in
Model at line 612
static bool
isIgnoringTouch(string|null $class = null)
Determine if the given model is ignoring touches.
in
Model at line 648
static void
shouldBeStrict(bool $shouldBeStrict = true)
Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.
Boot-only. Toggles worker-wide strict-mode flags that apply to every model operation across all coroutines.
in
Model at line 661
static void
preventLazyLoading(bool $value = true)
Prevent model relationships from being lazy loaded.
Boot-only. The flag persists in a static property for the worker lifetime and applies to every relationship access across all coroutines.
in
Model at line 672
static void
automaticallyEagerLoadRelationships(bool $value = true)
Determine if model relationships should be automatically eager loaded when accessed.
Boot-only. The flag persists in a static property for the worker lifetime and applies to every relationship access across all coroutines.
in
Model at line 685
static void
handleLazyLoadingViolationUsing(callable|null $callback)
Register a callback that is responsible for handling lazy loading violations.
Boot-only. The callback persists in a static property for the worker lifetime and runs on every lazy-loading violation across all coroutines.
in
Model at line 696
static void
preventSilentlyDiscardingAttributes(bool $value = true)
Prevent non-fillable attributes from being silently discarded.
Boot-only. The flag persists in a static property for the worker lifetime and applies to every mass assignment across all coroutines.
in
Model at line 710
static void
handleDiscardedAttributeViolationUsing(callable|null $callback)
Register a callback that is responsible for handling discarded attribute violations.
Boot-only. The callback persists in a static property for the worker lifetime and runs on every discarded-attribute violation across all coroutines.
in
Model at line 721
static void
preventAccessingMissingAttributes(bool $value = true)
Prevent accessing missing attributes on retrieved models.
Boot-only. The flag persists in a static property for the worker lifetime and applies to every attribute access across all coroutines.
in
Model at line 735
static void
handleMissingAttributeViolationUsing(callable|null $callback)
Register a callback that is responsible for handling missing attribute violations.
Boot-only. The callback persists in a static property for the worker lifetime and runs on every missing-attribute violation across all coroutines.
in
Model at line 746
static void
reportRouteModelBindingExceptions(bool $value = true)
Report invalid value exceptions during implicit route model binding.
Boot-only. The flag persists in a static property for the worker lifetime and applies to every implicit route binding across all coroutines.
in
Model at line 759
static mixed
withoutBroadcasting(callable $callback)
Execute a callback without broadcasting any model events for all model types.
in
Model at line 775
static bool
isBroadcasting()
Determine if broadcasting is currently enabled.
in
Model at line 839
Model
forceFill(array $attributes)
Fill the model with an array of attributes. Force mass assignment.
in
Model at line 847
string
qualifyColumn(string $column)
Qualify the given column name by the model's table.
in
Model at line 862
array
qualifyColumns(array $columns)
Qualify the given columns with the model's table.
in
Model at line 874
Model
newInstance(array $attributes = [], bool $exists = false)
Create a new instance of the given model.
in
Model at line 901
Model
newFromBuilder(array|object $attributes = [], UnitEnum|string|null $connection = null)
Create a new model instance that is existing.
in
Model at line 919
static Builder
on(UnitEnum|string|null $connection = null)
Begin querying the model on a given connection.
in
Model at line 932
static Builder
onWriteConnection()
Begin querying the model on the write connection.
in
Model at line 943
static Collection
all(array|string $columns = ['*'])
Get all of the models from the database.
in
Model at line 956
static Builder
with(array|string $relations)
Begin querying a model with eager loading.
in
Model at line 984
Model
loadMorph(string $relation, array $relations)
Eager load relationships on the polymorphic relation of a model.
in
Model at line 1002
Model
loadMissing(array|string $relations)
Eager load relations on the model if they are not already eager loaded.
in
Model at line 1016
Model
loadAggregate(array|string $relations, Expression|string $column, string|null $function = null)
Eager load relation's column aggregations on the model.
in
Model at line 1028
Model
loadCount(array|string $relations)
Eager load relation counts on the model.
in
Model at line 1040
Model
loadMax(array|string $relations, Expression|string $column)
Eager load relation max column values on the model.
in
Model at line 1050
Model
loadMin(array|string $relations, Expression|string $column)
Eager load relation min column values on the model.
in
Model at line 1060
Model
loadSum(array|string $relations, Expression|string $column)
Eager load relation's column summations on the model.
in
Model at line 1070
Model
loadAvg(array|string $relations, Expression|string $column)
Eager load relation average column values on the model.
in
Model at line 1080
Model
loadExists(array|string $relations)
Eager load related model existence values on the model.
in
Model at line 1090
Model
loadMorphAggregate(string $relation, array $relations, Expression|string $column, string|null $function = null)
Eager load relationship column aggregation on the polymorphic relation of a model.
in
Model at line 1108
Model
loadMorphCount(string $relation, array $relations)
Eager load relationship counts on the polymorphic relation of a model.
in
Model at line 1118
Model
loadMorphMax(string $relation, array $relations, Expression|string $column)
Eager load relationship max column values on the polymorphic relation of a model.
in
Model at line 1128
Model
loadMorphMin(string $relation, array $relations, Expression|string $column)
Eager load relationship min column values on the polymorphic relation of a model.
in
Model at line 1138
Model
loadMorphSum(string $relation, array $relations, Expression|string $column)
Eager load relationship column summations on the polymorphic relation of a model.
in
Model at line 1148
Model
loadMorphAvg(string $relation, array $relations, Expression|string $column)
Eager load relationship average column values on the polymorphic relation of a model.
in
Model at line 1158
protected int|false
increment(string $column, mixed $amount = 1, array $extra = [])
Increment a column's value by a given amount.
in
Model at line 1168
protected int|false
decrement(string $column, mixed $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
in
Model at line 1178
protected int|false
incrementOrDecrement(string $column, mixed $amount, array $extra, string $method)
Run the increment or decrement method on the model.
in
Model at line 1213
bool
update(array $attributes = [], array $options = [])
Update the model in the database.
in
Model at line 1230
bool
updateOrFail(array $attributes = [], array $options = [])
Update the model in the database within a transaction.
in
Model at line 1245
bool
updateQuietly(array $attributes = [], array $options = [])
Update the model in the database without raising any events.
in
Model at line 1259
protected int|false
incrementQuietly(string $column, float|int $amount = 1, array $extra = [])
Increment a column's value by a given amount without raising any events.
in
Model at line 1271
protected int|false
decrementQuietly(string $column, float|int $amount = 1, array $extra = [])
Decrement a column's value by a given amount without raising any events.
in
Model at line 1284
protected int|false
incrementEach(array $columns, array $extra = [])
Increment each given column's value by the given amounts.
in
Model at line 1295
protected int|false
decrementEach(array $columns, array $extra = [])
Decrement each given column's value by the given amounts.
in
Model at line 1306
protected int|false
incrementEachQuietly(array $columns, array $extra = [])
Increment each given column's value by the given amounts without raising any events.
in
Model at line 1319
protected int|false
decrementEachQuietly(array $columns, array $extra = [])
Decrement each given column's value by the given amounts without raising any events.
in
Model at line 1332
protected int|false
incrementOrDecrementEach(array $columns, array $extra, string $method)
Run the incrementEach or decrementEach method on the model.
in
Model at line 1379
bool
push()
Save the model and all of its relationships.
in
Model at line 1408
bool
pushQuietly()
Save the model and all of its relationships without raising any events to the parent model.
in
Model at line 1418
bool
saveQuietly(array $options = [])
Save the model to the database without raising any events.
in
Model at line 1428
bool
save(array $options = [])
Save the model to the database.
in
Model at line 1477
bool
saveOrIgnore(array $options = [], array|string|null $uniqueBy = null)
Save the model to the database, ignoring specific unique constraint conflicts.
in
Model at line 1511
bool
saveOrFail(array $options = [])
Save the model to the database within a transaction.
in
Model at line 1521
protected void
finishSave(array $options)
Perform any actions that are necessary after the model is saved.
in
Model at line 1537
protected bool
performUpdate(Builder $query)
Perform a model update operation.
in
AsPivot at line 91
protected Builder
setKeysForSelectQuery(Builder $query)
Set the keys for a select query.
in
Model at line 1597
protected mixed
getKeyForSelectQuery()
Get the primary key value for a select query.
in
AsPivot at line 110
protected Builder
setKeysForSaveQuery(Builder $query)
Set the keys for a save update query.
in
Model at line 1624
protected mixed
getKeyForSaveQuery()
Get the primary key value for a save query.
in
Model at line 1657
protected bool
performInsert(Builder $query)
Perform a model insert operation.
in
Model at line 1716
protected bool
performInsertOrIgnore(Builder $query, array|string|null $uniqueBy)
Perform a model insert operation, ignoring specific unique constraint conflicts.
in
Model at line 1770
protected void
insertAndSetId(Builder $query, array $attributes)
Insert the given attributes and set the ID on the model.
in
Model at line 1782
static int
destroy(Collection|Collection|array|int|string $ids)
Destroy the models for the given IDs.
in
AsPivot at line 121
int
delete()
Delete the pivot model record from the database.
Returns affected row count (int) rather than bool|null because pivots use query builder deletion with compound keys.
in
Model at line 1859
int|bool|null
deleteQuietly()
Delete the model from the database without raising any events.
in
Model at line 1869
int|bool|null
deleteOrFail()
Delete the model from the database within a transaction.
in
Model at line 1883
int|bool|null
forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when the trait is missing.
in
Model at line 1895
static int
forceDestroy(Collection|Collection|array|int|string $ids)
Force a hard destroy on a soft deleted model.
This method protects developers from running forceDestroy when the trait is missing.
in
Model at line 1903
protected void
performDeleteOnModel()
Perform the actual delete query on this model instance.
in
Model at line 1935
Builder
newModelQuery()
Get a new query builder that doesn't have any global scopes or eager loading.
in
Model at line 1948
Builder
newQueryWithoutRelationships()
Get a new query builder with no relationships loaded.
in
Model at line 1959
Builder
registerGlobalScopes(Builder $builder)
Register the global scopes for this builder instance.
in
Model at line 1973
Builder
newQueryWithoutScopes()
Get a new query builder that doesn't have any global scopes.
in
Model at line 1985
Builder
newQueryWithoutScope(Scope|int|string $scope)
Get a new query instance without a given scope.
in
AsPivot at line 323
Builder
newQueryForRestoration(array|int|string $ids)
Get a new query to restore one or more models by their queueable IDs.
in
Model at line 2005
Builder
newEloquentBuilder(Builder $query)
Create a new Eloquent query builder for the model.
in
Model at line 2022
protected string|false
resolveCustomBuilderClass()
Resolve the custom Eloquent builder class from the model attributes.
in
Model at line 2030
protected Builder
newBaseQueryBuilder()
Get a new query builder instance for the connection.
in
Model at line 2041
Model
newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)
Create a new pivot model instance.
in
Model at line 2050
bool
hasNamedScope(string $scope)
Determine if the model has a given scope.
in
Model at line 2061
mixed
callNamedScope(string $scope, array $parameters = [])
Apply the given named scope if possible.
in
Model at line 2073
static protected bool
isScopeMethodWithAttribute(string $method)
Determine if the given method has a scope attribute.
in
Model at line 2096
static protected bool
isLegacyScopeMethod(string $scope)
Determine if the given method is a callable legacy local scope.
in
Model at line 2123
array
toArray()
Convert the model instance to an array.
in
Model at line 2136
string
toJson(int $options = 0)
Convert the model instance to JSON.
in
Model at line 2152
string
toPrettyJson(int $options = 0)
Convert the model instance to pretty print formatted JSON.
in
Model at line 2160
mixed
jsonSerialize()
Convert the object into something JSON serializable.
in
Model at line 2170
Model|null
fresh(array|string $with = [])
Reload a fresh model instance from the database.
in
Model at line 2187
Model
refresh()
Reload the current model instance with fresh attributes from the database.
in
Model at line 2201
Model
refreshForUpdate()
Reload the current model instance with fresh attributes from the database while locking it for updating.
in
Model at line 2218
protected Model
refreshUsingQuery(Builder $query)
Reload the current model instance using the given query.
in
Model at line 2242
Model
replicate(array|null $except = null)
Clone the model into a new, non-existing instance.
in
Model at line 2271
Model
replicateQuietly(array|null $except = null)
Clone the model into a new, non-existing instance without raising any events.
in
Model at line 2279
bool
is(Model|null $model)
Determine if two models have the same ID and belong to the same table.
in
Model at line 2304
Connection
getConnection()
Get the database connection for the model.
in
Model at line 2312
string|null
getConnectionName()
Get the current connection name for the model.
in
Model at line 2322
Model
setConnection(UnitEnum|string|null $name)
Set the connection associated with the model.
in
Model at line 2332
static Connection
resolveConnection(UnitEnum|string|null $connection = null)
Resolve a connection instance.
in
Model at line 2341
static ConnectionResolverInterface|null
getConnectionResolver()
Get the connection resolver instance.
in
Model at line 2353
static void
setConnectionResolver(ConnectionResolverInterface $resolver)
Set the connection resolver instance.
Boot-only. The resolver persists in a static property for the worker lifetime and is used by every model's connection resolution across all coroutines.
in
Model at line 2364
static void
unsetConnectionResolver()
Unset the connection resolver for models.
Tests only. Clears the worker-wide connection resolver shared by every coroutine; concurrent model queries will fail or rebuild.
in
Model at line 2376
static protected mixed
resolveClassAttribute(string $attributeClass, string|null $property = null, string|null $class = null)
Resolve an attribute from the model class or its parents.
in
Model at line 2417
static protected bool
classDeclaresAttribute(string $attributeClass)
Determine whether a class directly declares an attribute.
in
Model at line 2432
static protected string|null
classPropertyDeclarer(string $property)
Resolve the nearest class that declares a property.
in
AsPivot at line 193
string
getTable()
Get the table associated with the model.
in
Model at line 2469
string
getKeyName()
Get the primary key for the model.
in
Model at line 2489
string
getQualifiedKeyName()
Get the table qualified key name.
in
Model at line 2497
string
getKeyType()
Get the auto-incrementing key type.
in
Model at line 2517
bool
getIncrementing()
Get the value indicating whether the IDs are incrementing.
in
Model at line 2537
mixed
getKey()
Get the value of the model's primary key.
in
AsPivot at line 303
mixed
getQueueableId()
Get the queueable identity for the entity.
in
Model at line 2553
array
getQueueableRelations()
Get the queueable relationships for the entity.
in
Model at line 2585
string|null
getQueueableConnection()
Get the queueable connection for the entity.
in
Model at line 2593
mixed
getRouteKey()
Get the value of the model's route key.
in
Model at line 2601
string
getRouteKeyName()
Get the route key for the model.
in
Model at line 2610
mixed
resolveRouteBinding(mixed $value, string|null $field = null)
Retrieve the model for a bound value.
in
Model at line 2618
mixed
resolveSoftDeletableRouteBinding(mixed $value, string|null $field = null)
Retrieve the model for a bound value.
in
Model at line 2626
mixed
resolveChildRouteBinding(string $childType, mixed $value, string|null $field)
Retrieve the child model for a bound value.
in
Model at line 2634
mixed
resolveSoftDeletableChildRouteBinding(string $childType, mixed $value, string|null $field)
Retrieve the child model for a bound value.
in
Model at line 2644
protected Relation
resolveChildRouteBindingQuery(string $childType, mixed $value, string|null $field)
Retrieve the child model query for a bound value.
in
Model at line 2663
protected string
childRouteBindingRelationshipName(string $childType)
Retrieve the child route model binding relationship name for the given child type.
in
Model at line 2676
Builder|Relation
resolveRouteBindingQuery(Model|Builder|Relation $query, mixed $value, string|null $field = null)
Retrieve the model for a bound value.
in
Model at line 2692
protected bool
isValidIntegerRouteKey(mixed $value)
Determine if the given value could address a row in an integer key column.
in
Model at line 2713
protected never
handleInvalidRouteKey(mixed $value, string $field)
Throw an exception for the given invalid route key.
in
AsPivot at line 209
string
getForeignKey()
Get the foreign key column name.
in
Model at line 2729
int
getPerPage()
Get the number of models to return per page.
in
Model at line 2747
static bool
isSoftDeletable()
Determine if the model is soft deletable.
in
Model at line 2755
static bool
isPrunable()
Determine if the model is prunable.
in
Model at line 2763
static bool
isMassPrunable()
Determine if the model is mass prunable.
in
Model at line 2771
static bool
preventsLazyLoading()
Determine if lazy loading is disabled.
in
Model at line 2779
static bool
isAutomaticallyEagerLoadingRelationships()
Determine if relationships are being automatically eager loaded when accessed.
in
Model at line 2787
static bool
preventsSilentlyDiscardingAttributes()
Determine if discarding guarded attribute fills is disabled.
in
Model at line 2795
static bool
preventsAccessingMissingAttributes()
Determine if accessing missing attributes is disabled.
in
Model at line 2803
static bool
reportsRouteModelBindingExceptions()
Determine if invalid value exceptions during implicit route model binding should be reported.
in
Model at line 2811
string
broadcastChannelRoute()
Get the broadcast channel route definition that is associated with the given entity.
in
Model at line 2819
string
broadcastChannel()
Get the broadcast channel name that is associated with the given entity.
in
Model at line 2827
static void
flushGuardableColumns()
Flush cached guardable column metadata.
in
Model at line 2844
static void
flushState()
Flush all static state.
in
Model at line 2888
mixed
__get(string $key)
Dynamically retrieve attributes on the model.
in
Model at line 2896
void
__set(string $key, mixed $value)
Dynamically set attributes on the model.
in
Model at line 2906
bool
offsetExists(mixed $offset)
Determine if the given attribute exists.
in
Model at line 2928
mixed
offsetGet(mixed $offset)
Get the value for a given offset.
in
Model at line 2939
void
offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
in
Model at line 2949
void
offsetUnset(mixed $offset)
Unset the value for a given offset.
in
Model at line 2962
bool
__isset(string $key)
Determine if an attribute or relation exists on the model.
in
Model at line 2970
void
__unset(string $key)
Unset an attribute on the model.
in
Model at line 2980
mixed
__call(string $method, array $parameters)
Handle dynamic method calls into the model.
in
Model at line 3003
static mixed
__callStatic(string $method, array $parameters)
Handle dynamic static method calls into the model.
in
Model at line 3015
string
__toString()
Convert the model to its string representation.
in
Model at line 3025
CanBeEscapedWhenCastToString
escapeWhenCastingToString(bool $escape = true)
Indicate that the object's string representation should be escaped when __toString is invoked.
in
Model at line 3037
array
__sleep()
Prepare the object for serialization.
in
Model at line 3061
void
__wakeup()
When a model is being unserialized, check if it needs to be booted.
in
AsPivot at line 44
static AsPivot
fromAttributes(Model $parent, array $attributes, string $table, bool $exists = false)
Create a new pivot model instance.
in
AsPivot at line 71
static AsPivot
fromRawAttributes(Model $parent, array $attributes, string $table, bool $exists = false)
Create a new pivot model from raw values returned from a query.
in
AsPivot at line 145
protected Builder
getDeleteQuery()
Get the query builder for a delete operation on the pivot.
in
AsPivot at line 161
protected Builder
applyPivotConstraints(Builder $query)
Apply the relation-owned predicates to a pivot identity query.
in
AsPivot at line 179
protected mixed
getPivotKeyForQuery(string $column)
Get a pivot key for a query.
in
AsPivot at line 217
string
getRelatedKey()
Get the "related key" column name.
in
AsPivot at line 225
string
getOtherKey()
Get the "related key" column name.
in
AsPivot at line 235
AsPivot
setPivotKeys(string $foreignKey, string $relatedKey)
Set the key names for the pivot model instance.
in
AsPivot at line 250
AsPivot
setPivotConstraints(array $constraints)
Set the relation-owned predicates for the pivot model.
in
AsPivot at line 262
AsPivot
setRelatedModel(Model|null $related = null)
Set the related model of the relationship.
in
AsPivot at line 272
bool
hasTimestampAttributes(array|null $attributes = null)
Determine if the pivot model or given attributes has timestamp attributes.