class DeviceCode extends Model

Traits

Constants

protected IGNORE_ON_TOUCH_CONTEXT_KEY

Context key for storing models that should ignore touch.

protected AUTOMATIC_EAGER_LOADING_SUPPRESSED_CONTEXT_KEY

Context key for suppressing automatic eager loading of relationships.

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.

protected SYNC_CHANGES_CONTEXT_KEY

Context key for passing a write's changes through the synchronization hook.

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 to native types.

protected array $classCastCache

The attributes that have been cast using custom classes.

from  HasAttributes
protected array<string, array<string, mixed>> $classCastStoredValues

The stored attributes each cached class cast was created from or last wrote.

from  HasAttributes
protected array $attributeCastCache

The attributes that have been cast using "Attribute" return type mutators.

from  HasAttributes
protected array<string, array<string, mixed>> $attributeCastStoredValues

The stored attributes each cached accessor was created from or last wrote.

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 string[] $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 string[] $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.

bool $usesUniqueIds

Indicates if the model uses unique ids.

from  HasUniqueIds
protected array<int, string> $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 guarded attributes on the model.

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 database table used by the model.

protected string|null $primaryKey

The primary key for the model.

from  Model
protected string $keyType

The "type" of the primary key ID.

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
protected list<string> $refreshes

The attributes that should be refreshed after the model is written.

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<mixed>>|false> $resolvedBuilderClasses

Cache of resolved custom builder classes per model.

from  Model
static protected array<class-string<self>, bool> $resolvesDefaultConnections

Cache of whether each model class resolves its connection without overriding the resolution methods.

from  Model
static protected array<string, null|object> $classAttributes

Cache of resolved class attributes.

from  Model
static protected array<string, bool|string|UnitEnum> $classAttributeOverrides

Cache of whether class attributes override inherited properties.

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
string $id
null|int|string $user_id
null|string $provider
string $client_id
$consent_id
string $user_code
array $scopes
null|array<string, list<string>> $resources
bool $revoked
null|CarbonInterface $user_approved_at
null|CarbonInterface $last_polled_at
null|CarbonInterface $expires_at

Methods

void
initializeHasAttributes()

Initialize the trait.

array
attributesToArray()

Convert the model's attributes to an array.

array
addDateAttributesToArray(array $attributes)

Add the date attributes to the attributes array.

array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)

Add the mutated attributes to the attributes array.

array
addCastAttributesToArray(array $attributes, array $mutatedAttributes)

Add the casted attributes to the attributes array.

array
getArrayableAttributes()

Get an attribute array of all arrayable attributes.

array
getArrayableAppends()

Get all of the appendable values that are arrayable.

array
relationsToArray()

Get the model's relationships in array form.

array
getArrayableRelations()

Get an attribute array of all arrayable relations.

array
getArrayableItems(array $values)

Get an attribute array of all arrayable values.

bool
hasAttribute(string $key)

Determine whether an attribute exists on the model.

mixed
getAttribute(string $key)

Get an attribute from the model.

mixed
throwMissingAttributeExceptionIfApplicable(string $key)

Either throw a missing attribute exception or return null depending on Eloquent's configuration.

mixed
getAttributeValue(string $key)

Get a plain attribute (not a relationship).

mixed
getAttributeFromArray(string $key)

Get an attribute from the $attributes array.

mixed
getRelationValue(string $key)

Get a relationship.

bool
isRelation(string $key)

Determine if the given key is a relationship method on the model.

mixed
handleLazyLoadingViolation(string $key)

Handle a lazy loading violation.

mixed
getRelationshipFromMethod(string $method)

Get a relationship value from a method.

bool
hasGetMutator(string $key)

Determine if a get mutator exists for an attribute.

bool
hasAttributeMutator(string $key)

Determine if a "Attribute" return type marked mutator exists for an attribute.

bool
hasAttributeGetMutator(string $key)

Determine if a "Attribute" return type marked get mutator exists for an attribute.

bool
hasAnyGetMutator(string $key)

Determine if any get mutator exists for an attribute.

mixed
mutateAttribute(string $key, mixed $value)

Get the value of an attribute using its mutator.

mixed
mutateAttributeMarkedAttribute(string $key, mixed $value)

Get the value of an "Attribute" return type marked attribute using its mutator.

mixed
mutateAttributeForArray(string $key, mixed $value)

Get the value of an attribute using its mutator for array conversion.

mergeCasts(array $casts)

Merge new casts with existing casts on the model.

void
flushCastCaches()

Flush the per-instance cast metadata caches.

array
ensureCastsAreStringValues(array $casts)

Ensure that the given casts are strings.

mixed
castAttribute(string $key, mixed $value)

Cast an attribute to a native PHP type.

mixed
getClassCastableAttributeValue(string $key, mixed $value)

Cast the given attribute using a custom cast class.

mixed
getEnumCastableAttributeValue(string $key, mixed $value)

Cast the given attribute to an enum.

string
getCastType(string $key)

Get the type of cast for a model attribute.

mixed
deviateClassCastableAttribute(string $method, string $key, mixed $value)

Increment or decrement the given attribute using the custom cast class.

mixed
serializeClassCastableAttribute(string $key, mixed $value)

Serialize the given attribute using the custom cast class.

bool
compareClassCastableAttribute(string $key, mixed $original, mixed $value)

Compare two values for the given attribute using the custom cast class.

bool
isCustomDateTimeCast(string $cast)

Determine if the cast type is a custom date time cast.

bool
isImmutableCustomDateTimeCast(string $cast)

Determine if the cast type is an immutable custom date time cast.

bool
isDecimalCast(string $cast)

Determine if the cast type is a decimal cast.

void
ensureValidDecimalScale(string $cast, string $attribute)

Ensure the decimal cast has a valid scale.

mixed
setAttribute(string|int $key, mixed $value)

Set a given attribute on the model.

bool
hasSetMutator(string $key)

Determine if a set mutator exists for an attribute.

bool
hasAttributeSetMutator(string $key)

Determine if an "Attribute" return type marked set mutator exists for an attribute.

mixed
setMutatedAttributeValue(string $key, mixed $value)

Set the value of an attribute using its mutator.

mixed
setAttributeMarkedMutatedAttributeValue(string $key, mixed $value)

Set the value of a "Attribute" return type marked attribute using its mutator.

bool
isDateAttribute(string $key)

Determine if the given attribute is a date or date castable.

fillJsonAttribute(string $key, mixed $value)

Set a given JSON attribute on the model.

void
setClassCastableAttribute(string $key, mixed $value)

Set the value of a class castable attribute.

void
setEnumCastableAttribute(string $key, mixed $value)

Set the value of an enum castable attribute.

mixed
getEnumCaseFromValue(string $enumClass, string|int $value)

Get an enum case instance from a given class and value.

string|int
getStorableEnumValue(string $expectedEnum, mixed $value)

Get the storable value from the given enum.

array
getArrayAttributeWithValue(string $path, string $key, mixed $value)

Get an array attribute with the given key and value set.

array
getArrayAttributeByKey(string $key)

Get an array attribute or return an empty array if it is not set.

string
castAttributeAsJson(string $key, mixed $value)

Cast the given attribute to JSON.

int
getJsonCastFlags(string $key)

Get the JSON casting flags for the given attribute.

string|false
asJson(mixed $value, int $flags = 0)

Encode the given value as JSON.

mixed
fromJson(string|int|float|null $value, bool $asObject = false)

Decode the given JSON back into an array or object.

mixed
fromEncryptedString(string $value)

Decrypt the given encrypted string.

string
castAttributeAsEncryptedString(string $key, mixed $value)

Cast the given attribute to an encrypted string.

static void
encryptUsing(Encrypter|null $encrypter)

Set the encrypter instance that will be used to encrypt attributes.

static Encrypter
currentEncrypter()

Get the current encrypter being used by the model.

string|null
castAttributeAsHashedString(string $key, mixed $value)

Cast the given attribute to a hashed string.

float
fromFloat(mixed $value)

Decode the given float.

string
asDecimal(float|int|string $value, int $decimals)

Return a decimal as string.

CarbonInterface
asDate(mixed $value)

Return a timestamp as DateTime object with time set to 00:00:00.

CarbonInterface
asDateTime(mixed $value)

Return a timestamp as DateTime object.

bool
isStandardDateFormat(string $value)

Determine if the given value is a standard date format.

string|null
fromDateTime(mixed $value)

Convert a DateTime to a storable string.

int
asTimestamp(mixed $value)

Return a timestamp as unix timestamp.

string
serializeDate(DateTimeInterface $date)

Prepare a date for array / JSON serialization.

array
getDates()

Get the attributes that should be converted to dates.

string
getDateFormat()

Get the format for database stored dates.

setDateFormat(string $format)

Set the date format used by the model.

bool
hasCast(string $key, array|string|null $types = null)

Determine whether an attribute should be cast to a native type.

array
getCasts()

Get the attributes that should be cast.

array
casts()

Get the attributes that should be cast.

array
defaults()

Get the default attribute values for the model.

void
mergeDefaultAttributes()

Merge the default values into the model's attributes.

bool
isDateCastable(string $key)

Determine whether a value is Date / DateTime castable for inbound manipulation.

bool
isDateCastableWithCustomFormat(string $key)

Determine whether a value is Date / DateTime custom-castable for inbound manipulation.

bool
isJsonCastable(string $key)

Determine whether a value is JSON castable for inbound manipulation.

bool
isEncryptedCastable(string $key)

Determine whether a value is an encrypted castable for inbound manipulation.

bool
isEncryptedClassCastable(string $key)

Determine whether a value is an encrypted class castable for inbound manipulation.

bool
isClassCastable(string $key)

Determine if the given key is cast using a custom class.

bool
isEnumCastable(string $key)

Determine if the given key is cast using an enum.

bool
isClassDeviable(string $key)

Determine if the key is deviable using a custom class.

bool
isClassSerializable(string $key)

Determine if the key is serializable using a custom class.

bool
isClassComparable(string $key)

Determine if the key is comparable using a custom class.

mixed
resolveCasterClass(string $key)

Resolve the custom caster class for a given key.

static void
flushCasterCache()

Flush the caster cache for the model.

string
parseCasterClass(string $class)

Parse the given caster class, removing any arguments.

void
mergeAttributesFromCachedCasts()

Merge the cast class and attribute cast attributes back into the model.

void
mergeAttributeFromCachedCasts(string $key)

Merge the cast class and attribute cast attribute back into the model.

void
mergeAttributesFromClassCasts()

Merge the cast class attributes back into the model.

void
mergeAttributeFromClassCasts(string $key)

Merge the cast class attribute back into the model.

void
mergeAttributesFromAttributeCasts()

Merge the cast class attributes back into the model.

void
mergeAttributeFromAttributeCasts(string $key)

Merge the cast class attribute back into the model.

bool
mergeCachedCastAttributes(array $attributes, array $storedValues)

Merge cached cast values, advance their baseline, and indicate whether stored replacements took precedence.

array
normalizeCastClassResponse(string $key, mixed $value)

Normalize the response from a custom class caster.

array
getAttributes()

Get all of the current attributes on the model.

array
getAttributesForInsert()

Get all of the current attributes on the model for an insert operation.

array
prepareBinaryAttributesForDatabase(array $attributes)

Wrap raw binary attribute bytes or streams for database binding.

mixed
encodeBinaryAttributeForDatabase(string $key, mixed $value)

Encode a binary attribute's cast value, such as a UUID string, for database binding.

setRawAttributes(array $attributes, bool $sync = false)

Set the array of model attributes. No checking is done.

mixed
getOriginal(string|null $key = null, mixed $default = null)

Get the model's original attribute values.

mixed
getOriginalWithoutRewindingModel(string|null $key = null, mixed $default = null)

Get the model's original attribute values.

mixed
getRawOriginal(string|null $key = null, mixed $default = null)

Get the model's raw original attribute values.

array
only(mixed $attributes)

Get a subset of the model's attributes.

array
except(mixed $attributes)

Get all attributes except the given ones.

syncOriginal()

Sync the original attributes with the current.

syncOriginalAttribute(string $attribute)

Sync a single original attribute with its current value.

syncOriginalAttributes(array|string $attributes)

Sync multiple original attribute with their current values.

syncChanges()

Sync the changed attributes.

bool
isDirty(array|string|null $attributes = null)

Determine if the model or any of the given attribute(s) have been modified.

bool
isClean(array|string|null $attributes = null)

Determine if the model or all the given attribute(s) have remained the same.

discardChanges()

Discard attribute changes and reset the attributes to their original state.

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.

bool
hasChanges(array $changes, array|string|null $attributes = null)

Determine if any of the given attributes were changed when the model was last saved.

array
getDirty()

Get the attributes that have been changed since the last sync.

array
getDirtyForUpdate()

Get the attributes that have been changed since the last sync for an update operation.

array
getChanges()

Get the attributes that were changed when the model was last saved.

array
getPrevious()

Get the attributes that were previously original before the model was last saved.

bool
originalIsEquivalent(string $key)

Determine if the new and old values for a given key are equivalent.

bool
jsonIsEquivalent(string|int|float|null $attribute, string|int|float|null $original, bool $asObject)

Compare JSON values using the structure exposed by their cast.

mixed
transformModelValue(string $key, mixed $value)

Transform a raw model value using mutators, casts, etc.

append(array|string $attributes)

Append attributes to query when building a query.

array
getAppends()

Get the accessors that are being appended to model arrays.

setAppends(array $appends)

Set the accessors to append to model arrays.

mergeAppends(array $appends)

Merge new appended attributes with existing appended attributes on the model.

bool
hasAppended(string $attribute)

Return whether the accessor attribute has been appended.

withoutAppends()

Remove all appended properties from the model.

array
getMutatedAttributes()

Get the mutated attributes for a given instance.

static void
cacheMutatedAttributes(object|string $classOrInstance)

Extract and cache all the mutated attributes of a class.

static array
getMutatorMethods(mixed $class)

Get all of the attribute mutator methods.

static array
getAttributeMarkedMutatorMethods(mixed $class)

Get all of the "Attribute" return typed attribute mutator methods.

static void
bootHasEvents()

Boot the has event trait for a model.

static array
resolveObserveAttributes()

Resolve the observe class names from the attributes.

static void
observe(object|array|string $classes)

Register observers with the model.

void
registerObserver(object|string $class)

Register a single observer with the model.

array
getObservableEvents()

Get the observable event names.

setObservableEvents(array $observables)

Set the observable event names.

void
addObservableEvents(array|string $observables)

Add an observable event name.

void
removeObservableEvents(array|string $observables)

Remove an observable event name.

static void
registerModelEvent(string $event, mixed $callback)

Register a model event with the dispatcher.

mixed
fireModelEvent(string $event, bool $halt = true)

Fire the given event for the model.

mixed
fireCustomModelEvent(string $event, string $method)

Fire a custom model event for the given event.

mixed
filterModelEventResults(mixed $result)

Filter the model event results.

static void
retrieved(mixed $callback)

Register a retrieved model event with the dispatcher.

static void
saving(mixed $callback)

Register a saving model event with the dispatcher.

static void
saved(mixed $callback)

Register a saved model event with the dispatcher.

static void
updating(mixed $callback)

Register an updating model event with the dispatcher.

static void
updated(mixed $callback)

Register an updated model event with the dispatcher.

static void
creating(mixed $callback)

Register a creating model event with the dispatcher.

static void
created(mixed $callback)

Register a created model event with the dispatcher.

static void
replicating(mixed $callback)

Register a replicating model event with the dispatcher.

static void
deleting(mixed $callback)

Register a deleting model event with the dispatcher.

static void
deleted(mixed $callback)

Register a deleted model event with the dispatcher.

static void
flushEventListeners()

Remove all the event listeners for the model.

array
dispatchesEvents()

Get the event map for the model.

static Dispatcher|null
getEventDispatcher()

Get the event dispatcher instance.

static void
setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

static void
unsetEventDispatcher()

Unset the event dispatcher for models.

static mixed
withoutEvents(callable $callback)

Execute a callback without firing any model events for any model type.

static bool
eventsDisabled()

Determine if model events are currently disabled for this coroutine.

static void
bootHasGlobalScopes()

Boot the has global scopes trait for a model.

static array
resolveGlobalScopeAttributes()

Resolve the global scope class names from the attributes.

static mixed
addGlobalScope(Scope|Closure|string $scope, Scope|Closure|null $implementation = null)

Register a new global scope on the model.

static void
addGlobalScopes(array $scopes)

Register multiple global scopes on the model.

static bool
hasGlobalScope(Scope|int|string $scope)

Determine if a model has a global scope.

static Scope|Closure|null
getGlobalScope(Scope|int|string $scope)

Get a global scope registered with the model.

static array
getAllGlobalScopes()

Get all of the global scopes that are currently registered.

static void
setAllGlobalScopes(array $scopes)

Set the current global scopes.

array
getGlobalScopes()

Get the global scopes for this class instance.

void
initializeHasRelationships()

Initialize the HasRelationships trait.

Closure|null
relationResolver(string $class, string $key)

Get the dynamic relation resolver if defined or inherited, or return null.

static void
resolveRelationUsing(string $name, Closure $callback)

Define a dynamic relation resolver.

bool
hasRelationAutoloadCallback()

Determine if a relationship autoloader callback has been defined.

autoloadRelationsUsing(Closure $callback, mixed $context = null)

Define an automatic relationship autoloader callback for this model and its relations.

bool
attemptToAutoloadRelation(string $key)

Attempt to autoload the given relationship using the autoload callback.

void
invokeRelationAutoloadCallbackFor(string $key, array $tuples)

Invoke the relationship autoloader callback for the given relationships.

void
propagateRelationAutoloadCallbackToRelation(string $key, mixed $models)

Propagate the relationship autoloader callback to the given related models.

hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null)

Define a one-to-one relationship.

newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)

Instantiate a new HasOne relationship.

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.

newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)

Instantiate a new HasOneThrough relationship.

morphOne(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)

Define a polymorphic one-to-one relationship.

newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)

Instantiate a new MorphOne relationship.

belongsTo(string $related, string|null $foreignKey = null, string|null $ownerKey = null, string|null $relation = null)

Define an inverse one-to-one or many relationship.

newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)

Instantiate a new BelongsTo relationship.

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.

morphEagerTo(string $name, string $type, string $id, string|null $ownerKey)

Define a polymorphic, inverse one-to-one or many relationship.

morphInstanceTo(string|int $target, string $name, string $type, string $id, string|null $ownerKey)

Define a polymorphic, inverse one-to-one or many relationship.

newMorphTo(Builder $query, Model $parent, string $foreignKey, string|null $ownerKey, string $type, string $relation)

Instantiate a new MorphTo relationship.

static string
getActualClassNameForMorph(string|int $class)

Retrieve the actual class name for a given morph class.

string
guessBelongsToRelation()

Guess the "belongs to" relationship name.

through(string|HasOneOrMany $relationship)

Create a pending has-many-through or has-one-through relationship.

hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null)

Define a one-to-many relationship.

newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)

Instantiate a new HasMany relationship.

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.

newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)

Instantiate a new HasManyThrough relationship.

morphMany(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)

Define a polymorphic one-to-many relationship.

newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)

Instantiate a new MorphMany relationship.

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.

newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null)

Instantiate a new BelongsToMany relationship.

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.

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.

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.

string|null
guessBelongsToManyRelation()

Get the relationship name of the belongsToMany relationship.

string
joiningTable(string $related, Model|null $instance = null)

Get the joining table name for a many-to-many relation.

string
joiningTableSegment()

Get this model's half of the intermediate table name for belongsToMany relationships.

bool
touches(string $relation)

Determine if the model touches a given relation.

void
touchOwners()

Touch the owning relations of the model.

array
getMorphs(string $name, string|null $type, string|null $id)

Get the polymorphic relationship columns.

string
getMorphClass()

Get the class name for polymorphic relations.

newRelatedInstance(string $class)

Create a new model instance for a related model.

newRelatedThroughInstance(string $class)

Create a new model instance for a related "through" model.

array
getRelations()

Get all the loaded relations for the instance.

mixed
getRelation(string $relation)

Get a specified relationship.

bool
relationLoaded(string $key)

Determine if the given relation is loaded.

setRelation(string $relation, mixed $value)

Set the given relationship on the model.

unsetRelation(string $relation)

Unset a loaded relationship.

setRelations(array $relations)

Set the entire relations array on the model.

withRelationshipAutoloading()

Enable relationship autoloading for this model.

withoutRelations()

Duplicate the instance and unset all the loaded relations.

withoutRelation(array|string $relations)

Duplicate the instance and unset the given loaded relations.

unsetRelations()

Unset all the loaded relations for the instance.

array
getTouchedRelations()

Get the relationships that are touched on save.

setTouchedRelations(array $touches)

Set the relationships that are touched on save.

void
initializeHasTimestamps()

Initialize the HasTimestamps trait.

bool
touch(array|string|null $attribute = null)

Update the model's update timestamp.

bool
touchQuietly(array|string|null $attribute = null)

Update the model's update timestamp without raising any events.

updateTimestamps()

Update the creation and update timestamps.

setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

CarbonInterface
freshTimestamp()

Get a fresh timestamp for the model.

string
freshTimestampString()

Get a fresh timestamp for the model.

bool
usesTimestamps()

Determine if the model uses timestamps.

string|null
getCreatedAtColumn()

Get the name of the "created at" column.

string|null
getUpdatedAtColumn()

Get the name of the "updated at" column.

string|null
getQualifiedCreatedAtColumn()

Get the fully-qualified "created at" column.

string|null
getQualifiedUpdatedAtColumn()

Get the fully-qualified "updated at" column.

static mixed
withoutTimestamps(callable $callback)

Disable timestamps for the current class during the given callback scope.

static mixed
withoutTimestampsOn(array $models, callable $callback)

Disable timestamps for the given model classes during the given callback scope.

static bool
isIgnoringTimestamps(string|null $class = null)

Determine if the given model is ignoring timestamps / touches.

bool
usesUniqueIds()

Determine if the model uses unique ids.

void
setUniqueIds()

Generate unique keys for the model.

string|null
newUniqueId()

Generate a new key for the model.

array
uniqueIds()

Get the columns that should receive a unique identifier.

void
initializeHidesAttributes()

Initialize the HidesAttributes trait.

array
getHidden()

Get the hidden attributes for the model.

setHidden(array $hidden)

Set the hidden attributes for the model.

mergeHidden(array $hidden)

Merge new hidden attributes with existing hidden attributes on the model.

array
getVisible()

Get the visible attributes for the model.

setVisible(array $visible)

Set the visible attributes for the model.

mergeVisible(array $visible)

Merge new visible attributes with existing visible attributes on the model.

makeVisible(array|string|null $attributes)

Make the given, typically hidden, attributes visible.

makeVisibleIf(bool|Closure $condition, array|string|null $attributes)

Make the given, typically hidden, attributes visible if the given truth test passes.

makeHidden(array|string|null $attributes)

Make the given, typically visible, attributes hidden.

makeHiddenIf(bool|Closure $condition, array|string|null $attributes)

Make the given, typically visible, attributes hidden if the given truth test passes.

void
initializeGuardsAttributes()

Initialize the GuardsAttributes trait.

static array
guardConfiguration()

Resolve the nearest guard configuration for the model class.

static array|null
guardConfigurationFromTraits(array $traits)

Resolve guard configuration declared by traits at one class level.

array
getFillable()

Get the fillable attributes for the model.

fillable(array $fillable)

Set the fillable attributes for the model.

mergeFillable(array $fillable)

Merge new fillable attributes with existing fillable attributes on the model.

array
getGuarded()

Get the guarded attributes for the model.

guard(array $guarded)

Set the guarded attributes for the model.

mergeGuarded(array $guarded)

Merge new guarded attributes with existing guarded attributes on the model.

static void
unguard(bool $state = true)

Disable all mass assignable restrictions.

static void
reguard()

Enable the mass assignment restrictions.

static bool
isUnguarded()

Determine if the current state is "unguarded".

static mixed
unguarded(callable $callback)

Run the given callable while being unguarded.

bool
isFillable(string $key)

Determine if the given attribute may be mass assigned.

bool
isGuarded(string $key)

Determine if the given key is guarded.

bool
isGuardableColumn(string $key)

Determine if the given column is a valid, guardable column.

bool
totallyGuarded()

Determine if the model is totally guarded.

array
fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

mixed
withoutRecursion(callable $callback, mixed $default = null)

Prevent a method from being called multiple times on the same object within the same call stack.

static void
clearRecursiveCallValue(object $object, string $hash)

Remove an entry from the recursion cache for an object.

static array
getRecursiveCallStack(object $object)

Get the stack of methods being called recursively for the current object.

static WeakMap
getRecursionCache()

Get the current recursion cache being used by the model.

static mixed
setRecursiveCallValue(object $object, string $hash, mixed $value)

Set a value in the recursion cache for the given object and method.

toResource(string|null $resourceClass = null)

Create a new resource object for the given resource.

guessResource()

Guess the resource class for the model.

static array
guessResourceName()

Guess the resource class name for the model.

string|null
resolveResourceFromAttribute(string $class)

Get the resource class from the UseResource attribute.

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

newCollection(array $models = [])

Create a new Eloquent Collection instance.

string|null
resolveCollectionFromAttribute()

Resolve the collection class name from the CollectedBy attribute.

__construct(array $attributes = [])

Create a new Eloquent model instance.

from  Model
void
bootIfNotBooted()

Check if the model needs to be booted and if so, do it.

from  Model
static void
booting()

Perform any actions required before the model boots.

from  Model
static void
boot()

Bootstrap the model and its traits.

from  Model
static void
bootTraits()

Boot all of the bootable traits on the model.

from  Model
void
initializeTraits()

Initialize any initializable traits on the model.

from  Model
void
initializeModelAttributes()

Initialize the model attributes from class attributes.

from  Model
static void
booted()

Perform any actions required after the model boots.

from  Model
static void
whenBooted(Closure $callback)

Register a closure to be executed after the model has booted.

from  Model
static void
clearBootedModels()

Clear the list of booted models so they will be re-booted.

from  Model
static void
withoutTouching(callable $callback)

Disables relationship model touching for the current class during given callback scope.

from  Model
static void
withoutTouchingOn(array $models, callable $callback)

Disables relationship model touching for the given model classes during given callback scope.

from  Model
static bool
isIgnoringTouch(string|null $class = null)

Determine if the given model is ignoring touches.

from  Model
static void
shouldBeStrict(bool $shouldBeStrict = true)

Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.

from  Model
static void
preventLazyLoading(bool $value = true)

Prevent model relationships from being lazy loaded.

from  Model
static void
automaticallyEagerLoadRelationships(bool $value = true)

Determine if model relationships should be automatically eager loaded when accessed.

from  Model
static mixed
withoutAutomaticallyEagerLoadingRelationships(callable $callback)

Execute a callback without automatically eager loading relationships for the models it retrieves or makes.

from  Model
static void
handleLazyLoadingViolationUsing(callable|null $callback)

Register a callback that is responsible for handling lazy loading violations.

from  Model
static void
preventSilentlyDiscardingAttributes(bool $value = true)

Prevent non-fillable attributes from being silently discarded.

from  Model
static void
handleDiscardedAttributeViolationUsing(callable|null $callback)

Register a callback that is responsible for handling discarded attribute violations.

from  Model
static void
preventAccessingMissingAttributes(bool $value = true)

Prevent accessing missing attributes on retrieved models.

from  Model
static void
handleMissingAttributeViolationUsing(callable|null $callback)

Register a callback that is responsible for handling missing attribute violations.

from  Model
static void
reportRouteModelBindingExceptions(bool $value = true)

Report invalid value exceptions during implicit route model binding.

from  Model
static mixed
withoutBroadcasting(callable $callback)

Execute a callback without broadcasting any model events for all model types.

from  Model
static bool
isBroadcasting()

Determine if broadcasting is currently enabled.

from  Model
fill(array $attributes)

Fill the model with an array of attributes.

from  Model
forceFill(array $attributes)

Fill the model with an array of attributes. Force mass assignment.

from  Model
string
qualifyColumn(string $column)

Qualify the given column name by the model's table.

from  Model
array
qualifyColumns(array $columns)

Qualify the given columns with the model's table.

from  Model
newInstance(array $attributes = [], bool $exists = false)

Create a new instance of the given model.

from  Model
newFromBuilder(array|object $attributes = [], UnitEnum|string|null $connection = null)

Create a new model instance that is existing.

from  Model
static Builder
on(UnitEnum|string|null $connection = null)

Begin querying the model on a given connection.

from  Model
static Builder
onWriteConnection()

Begin querying the model on the write connection.

from  Model
static Collection
all(array|string $columns = ['*'])

Get all of the models from the database.

from  Model
static Builder
with(array|string $relations)

Begin querying a model with eager loading.

from  Model
load(array|string $relations)

Eager load relations on the model.

from  Model
loadMorph(string $relation, array $relations)

Eager load relationships on the polymorphic relation of a model.

from  Model
loadMissing(array|string $relations)

Eager load relations on the model if they are not already eager loaded.

from  Model
loadAggregate(array|string $relations, Expression|string $column, string|null $function = null)

Eager load relation's column aggregations on the model.

from  Model
loadCount(array|string $relations)

Eager load relation counts on the model.

from  Model
loadMax(array|string $relations, Expression|string $column)

Eager load relation max column values on the model.

from  Model
loadMin(array|string $relations, Expression|string $column)

Eager load relation min column values on the model.

from  Model
loadSum(array|string $relations, Expression|string $column)

Eager load relation's column summations on the model.

from  Model
loadAvg(array|string $relations, Expression|string $column)

Eager load relation average column values on the model.

from  Model
loadExists(array|string $relations)

Eager load related model existence values on the model.

from  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.

from  Model
loadMorphCount(string $relation, array $relations)

Eager load relationship counts on the polymorphic relation of a model.

from  Model
loadMorphMax(string $relation, array $relations, Expression|string $column)

Eager load relationship max column values on the polymorphic relation of a model.

from  Model
loadMorphMin(string $relation, array $relations, Expression|string $column)

Eager load relationship min column values on the polymorphic relation of a model.

from  Model
loadMorphSum(string $relation, array $relations, Expression|string $column)

Eager load relationship column summations on the polymorphic relation of a model.

from  Model
loadMorphAvg(string $relation, array $relations, Expression|string $column)

Eager load relationship average column values on the polymorphic relation of a model.

from  Model
int|false
increment(string $column, mixed $amount = 1, array $extra = [])

Increment a column's value by a given amount.

from  Model
int|false
decrement(string $column, mixed $amount = 1, array $extra = [])

Decrement a column's value by a given amount.

from  Model
int|false
incrementOrDecrement(string $column, mixed $amount, array $extra, string $method)

Run the increment or decrement method on the model.

from  Model
bool
update(array $attributes = [], array $options = [])

Update the model in the database.

from  Model
bool
updateOrFail(array $attributes = [], array $options = [])

Update the model in the database within a transaction.

from  Model
bool
updateQuietly(array $attributes = [], array $options = [])

Update the model in the database without raising any events.

from  Model
int
incrementQuietly(string $column, float|int $amount = 1, array $extra = [])

Increment a column's value by a given amount without raising any events.

from  Model
int
decrementQuietly(string $column, float|int $amount = 1, array $extra = [])

Decrement a column's value by a given amount without raising any events.

from  Model
int|false
incrementEach(array $columns, array $extra = [])

Increment each given column's value by the given amounts.

from  Model
int|false
decrementEach(array $columns, array $extra = [])

Decrement each given column's value by the given amounts.

from  Model
int
incrementEachQuietly(array $columns, array $extra = [])

Increment each given column's value by the given amounts without raising any events.

from  Model
int
decrementEachQuietly(array $columns, array $extra = [])

Decrement each given column's value by the given amounts without raising any events.

from  Model
int|false
incrementOrDecrementEach(array $columns, array $extra, string $method)

Run the incrementEach or decrementEach method on the model.

from  Model
bool
push()

Save the model and all of its relationships.

from  Model
bool
pushQuietly()

Save the model and all of its relationships without raising any events to the parent model.

from  Model
bool
saveQuietly(array $options = [])

Save the model to the database without raising any events.

from  Model
bool
save(array $options = [])

Save the model to the database.

from  Model
bool
saveOrIgnore(array $options = [], array|string|null $uniqueBy = null)

Save the model to the database, ignoring specific unique constraint conflicts.

from  Model
bool
saveOrFail(array $options = [])

Save the model to the database within a transaction.

from  Model
void
finishSave(array $options)

Perform any actions that are necessary after the model is saved.

from  Model
bool
performUpdate(Builder $query)

Perform a model update operation.

from  Model
setKeysForSelectQuery(Builder $query)

Set the keys for a select query.

from  Model
mixed
getKeyForSelectQuery()

Get the primary key value for a select query.

from  Model
setKeysForSaveQuery(Builder $query)

Set the keys for a save update query.

from  Model
mixed
getKeyForSaveQuery()

Get the primary key value for a save query.

from  Model
bool
performInsert(Builder $query)

Perform a model insert operation.

from  Model
bool
performInsertOrIgnore(Builder $query, array|string|null $uniqueBy)

Perform a model insert operation, ignoring specific unique constraint conflicts.

from  Model
void
insertAndSetId(Builder $query, array $attributes)

Insert the given attributes and set the ID on the model.

from  Model
void
refreshSavedAttributes(array $attributes)

Refresh the configured attributes after the model is saved.

from  Model
static int
destroy(Collection|Collection|array|int|string $ids)

Destroy the models for the given IDs.

from  Model
int|bool|null
delete()

Delete the model from the database.

from  Model
int|bool|null
deleteQuietly()

Delete the model from the database without raising any events.

from  Model
int|bool|null
deleteOrFail()

Delete the model from the database within a transaction.

from  Model
int|bool|null
forceDelete()

Force a hard delete on a soft deleted model.

from  Model
static int
forceDestroy(Collection|Collection|array|int|string $ids)

Force a hard destroy on a soft deleted model.

from  Model
void
performDeleteOnModel()

Perform the actual delete query on this model instance.

from  Model
static Builder
query()

Begin querying the model.

from  Model
newQuery()

Get a new query builder for the model's table.

from  Model
newModelQuery()

Get a new query builder that doesn't have any global scopes or eager loading.

from  Model
newQueryWithoutRelationships()

Get a new query builder with no relationships loaded.

from  Model
registerGlobalScopes(Builder $builder)

Register the global scopes for this builder instance.

from  Model
newQueryWithoutScopes()

Get a new query builder that doesn't have any global scopes.

from  Model
newQueryWithoutScope(Scope|int|string $scope)

Get a new query instance without a given scope.

from  Model
newQueryForRestoration(array|int|string $ids)

Get a new query to restore one or more models by their queueable IDs.

from  Model
newEloquentBuilder(Builder $query)

Create a new Eloquent query builder for the model.

from  Model
string|false
resolveCustomBuilderClass()

Resolve the custom Eloquent builder class from the model attributes.

from  Model
newBaseQueryBuilder()

Get a new query builder instance for the connection.

from  Model
newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)

Create a new pivot model instance.

from  Model
bool
hasNamedScope(string $scope)

Determine if the model has a given scope.

from  Model
mixed
callNamedScope(string $scope, array $parameters = [])

Apply the given named scope if possible.

from  Model
static bool
isScopeMethodWithAttribute(string $method)

Determine if the given method has a scope attribute.

from  Model
static bool
isLegacyScopeMethod(string $scope)

Determine if the given method is a callable legacy local scope.

from  Model
array
toArray()

Convert the model instance to an array.

from  Model
string
toJson(int $options = 0)

Convert the model instance to JSON.

from  Model
string
toPrettyJson(int $options = 0)

Convert the model instance to pretty print formatted JSON.

from  Model
mixed
jsonSerialize()

Convert the object into something JSON serializable.

from  Model
Model|null
fresh(array|string $with = [])

Reload a fresh model instance from the database.

from  Model
refresh()

Reload the current model instance with fresh attributes from the database.

from  Model
refreshForUpdate()

Reload the current model instance with fresh attributes from the database while locking it for updating.

from  Model
refreshUsingQuery(Builder $query)

Reload the current model instance using the given query.

from  Model
replicate(array|null $except = null)

Clone the model into a new, non-existing instance.

from  Model
replicateQuietly(array|null $except = null)

Clone the model into a new, non-existing instance without raising any events.

from  Model
bool
is(Model|null $model)

Determine if two models have the same ID and belong to the same table.

from  Model
bool
isNot(Model|null $model)

Determine if two models are not the same.

from  Model
getConnection()

Get the database connection for the model.

from  Model
bool
hasApplicableTransaction()

Check for an applicable transaction without borrowing a standard pooled connection.

from  Model
string
getConnectionDateFormat()

Get the date format of the query grammar of the model's connection.

from  Model
bool
usesDefaultConnectionResolution()

Determine whether this model uses the framework's normal connection resolution.

from  Model
string|null
getConnectionName()

Get the current connection name for the model.

setConnection(UnitEnum|string|null $name)

Set the connection associated with the model.

from  Model
static Connection
resolveConnection(UnitEnum|string|null $connection = null)

Resolve a connection instance.

from  Model
getConnectionResolver()

Get the connection resolver instance.

from  Model
static void
setConnectionResolver(ConnectionResolverInterface $resolver)

Set the connection resolver instance.

from  Model
static void
unsetConnectionResolver()

Unset the connection resolver for models.

from  Model
static mixed
resolveClassAttribute(string $attributeClass, string|null $property = null, string|null $class = null)

Resolve an attribute from the model class or its parents.

from  Model
bool
classAttributeOverridesProperty(string $attributeClass, string $property)

Determine whether a class attribute should override the property.

from  Model
static string|null
classPropertyDeclarer(string $property)

Resolve the nearest class that declares a property.

from  Model
string
getTable()

Get the table associated with the model.

from  Model
setTable(string $table)

Set the table associated with the model.

from  Model
string|null
getKeyName()

Get the primary key for the model.

from  Model
setKeyName(string|null $key)

Set the primary key for the model.

from  Model
string
getQualifiedKeyName()

Get the table qualified key name.

from  Model
string
getKeyType()

Get the auto-incrementing key type.

from  Model
setKeyType(string $type)

Set the data type for the primary key.

from  Model
bool
getIncrementing()

Get the value indicating whether the IDs are incrementing.

from  Model
setIncrementing(bool $value)

Set whether IDs are incrementing.

from  Model
mixed
getKey()

Get the value of the model's primary key.

from  Model
mixed
getQueueableId()

Get the queueable identity for the entity.

from  Model
array
getQueueableRelations()

Get the queueable relationships for the entity.

from  Model
string|null
getQueueableConnection()

Get the queueable connection for the entity.

from  Model
mixed
getRouteKey()

Get the value of the model's route key.

from  Model
string
getRouteKeyName()

Get the route key for the model.

from  Model
mixed
resolveRouteBinding(mixed $value, string|null $field = null)

Retrieve the model for a bound value.

from  Model
mixed
resolveSoftDeletableRouteBinding(mixed $value, string|null $field = null)

Retrieve the model for a bound value.

from  Model
mixed
resolveChildRouteBinding(string $childType, mixed $value, string|null $field)

Retrieve the child model for a bound value.

from  Model
mixed
resolveSoftDeletableChildRouteBinding(string $childType, mixed $value, string|null $field)

Retrieve the child model for a bound value.

from  Model
resolveChildRouteBindingQuery(string $childType, mixed $value, string|null $field)

Retrieve the child model query for a bound value.

from  Model
string
childRouteBindingRelationshipName(string $childType)

Retrieve the child route model binding relationship name for the given child type.

from  Model
resolveRouteBindingQuery(Model|Builder|Relation $query, mixed $value, string|null $field = null)

Retrieve the model for a bound value.

from  Model
bool
isValidIntegerRouteKey(mixed $value)

Determine if the given value could address a row in an integer key column.

from  Model
never
handleInvalidRouteKey(mixed $value, string $field)

Throw an exception for the given invalid route key.

from  Model
string
getForeignKey()

Get the default foreign key name for the model.

from  Model
int
getPerPage()

Get the number of models to return per page.

from  Model
setPerPage(int $perPage)

Set the number of models to return per page.

from  Model
static bool
isSoftDeletable()

Determine if the model is soft deletable.

from  Model
static bool
isPrunable()

Determine if the model is prunable.

from  Model
static bool
isMassPrunable()

Determine if the model is mass prunable.

from  Model
static bool
preventsLazyLoading()

Determine if lazy loading is disabled.

from  Model
static bool
isAutomaticallyEagerLoadingRelationships()

Determine if relationships are being automatically eager loaded when accessed.

from  Model
static bool
preventsSilentlyDiscardingAttributes()

Determine if discarding guarded attribute fills is disabled.

from  Model
static bool
preventsAccessingMissingAttributes()

Determine if accessing missing attributes is disabled.

from  Model
static bool
reportsRouteModelBindingExceptions()

Determine if invalid value exceptions during implicit route model binding should be reported.

from  Model
string
broadcastChannelRoute()

Get the broadcast channel route definition that is associated with the given entity.

from  Model
string
broadcastChannel()

Get the broadcast channel name that is associated with the given entity.

from  Model
static void
flushGuardableColumns()

Flush cached guardable column metadata.

from  Model
static void
flushState()

Flush all static state.

from  Model
mixed
__get(string $key)

Dynamically retrieve attributes on the model.

from  Model
void
__set(string $key, mixed $value)

Dynamically set attributes on the model.

from  Model
bool
offsetExists(mixed $offset)

Determine if the given attribute exists.

from  Model
mixed
offsetGet(mixed $offset)

Get the value for a given offset.

from  Model
void
offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

from  Model
void
offsetUnset(mixed $offset)

Unset the value for a given offset.

from  Model
bool
__isset(string $key)

Determine if an attribute or relation exists on the model.

from  Model
void
__unset(string $key)

Unset an attribute on the model.

from  Model
mixed
__call(string $method, array $parameters)

Handle dynamic method calls into the model.

from  Model
static mixed
__callStatic(string $method, array $parameters)

Handle dynamic static method calls into the model.

from  Model
string
__toString()

Convert the model to its string representation.

from  Model
escapeWhenCastingToString(bool $escape = true)

Indicate that the object's string representation should be escaped when __toString is invoked.

from  Model
array
__sleep()

Prepare the object for serialization.

from  Model
void
__wakeup()

When a model is being unserialized, check if it needs to be booted.

from  Model

Details

in HasAttributes at line 233
protected void initializeHasAttributes()

Initialize the trait.

Return Value

void

in HasAttributes at line 262
array attributesToArray()

Convert the model's attributes to an array.

Return Value

array

in HasAttributes at line 300
protected array addDateAttributesToArray(array $attributes)

Add the date attributes to the attributes array.

Parameters

array $attributes

Return Value

array

in HasAttributes at line 322
protected array addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)

Add the mutated attributes to the attributes array.

Parameters

array $attributes
array $mutatedAttributes

Return Value

array

in HasAttributes at line 351
protected array addCastAttributesToArray(array $attributes, array $mutatedAttributes)

Add the casted attributes to the attributes array.

Parameters

array $attributes
array $mutatedAttributes

Return Value

array

in HasAttributes at line 405
protected array getArrayableAttributes()

Get an attribute array of all arrayable attributes.

Return Value

array

in HasAttributes at line 413
protected array getArrayableAppends()

Get all of the appendable values that are arrayable.

Return Value

array

in HasAttributes at line 427
array relationsToArray()

Get the model's relationships in array form.

Return Value

array

in HasAttributes at line 469
protected array getArrayableRelations()

Get an attribute array of all arrayable relations.

Return Value

array

in HasAttributes at line 477
protected array getArrayableItems(array $values)

Get an attribute array of all arrayable values.

Parameters

array $values

Return Value

array

in HasAttributes at line 493
bool hasAttribute(string $key)

Determine whether an attribute exists on the model.

Parameters

string $key

Return Value

bool

in HasAttributes at line 509
mixed getAttribute(string $key)

Get an attribute from the model.

Parameters

string $key

Return Value

mixed

in HasAttributes at line 539
protected mixed throwMissingAttributeExceptionIfApplicable(string $key)

Either throw a missing attribute exception or return null depending on Eloquent's configuration.

Parameters

string $key

Return Value

mixed

Exceptions

MissingAttributeException

in HasAttributes at line 560
mixed getAttributeValue(string $key)

Get a plain attribute (not a relationship).

Parameters

string $key

Return Value

mixed

in HasAttributes at line 568
protected mixed getAttributeFromArray(string $key)

Get an attribute from the $attributes array.

Parameters

string $key

Return Value

mixed

in HasAttributes at line 578
mixed getRelationValue(string $key)

Get a relationship.

Parameters

string $key

Return Value

mixed

in HasAttributes at line 608
bool isRelation(string $key)

Determine if the given key is a relationship method on the model.

Parameters

string $key

Return Value

bool

in HasAttributes at line 623
protected mixed handleLazyLoadingViolation(string $key)

Handle a lazy loading violation.

Parameters

string $key

Return Value

mixed

Exceptions

LazyLoadingViolationException

in HasAttributes at line 648
protected mixed getRelationshipFromMethod(string $method)

Get a relationship value from a method.

Parameters

string $method

Return Value

mixed

Exceptions

LogicException

in HasAttributes at line 676
bool hasGetMutator(string $key)

Determine if a get mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 684
bool hasAttributeMutator(string $key)

Determine if a "Attribute" return type marked mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 704
bool hasAttributeGetMutator(string $key)

Determine if a "Attribute" return type marked get mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 720
bool hasAnyGetMutator(string $key)

Determine if any get mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 728
protected mixed mutateAttribute(string $key, mixed $value)

Get the value of an attribute using its mutator.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 738
protected mixed mutateAttributeMarkedAttribute(string $key, mixed $value)

Get the value of an "Attribute" return type marked attribute using its mutator.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 765
protected mixed mutateAttributeForArray(string $key, mixed $value)

Get the value of an attribute using its mutator for array conversion.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 790
HasAttributes mergeCasts(array $casts)

Merge new casts with existing casts on the model.

Parameters

array $casts

Return Value

HasAttributes

in HasAttributes at line 804
protected void flushCastCaches()

Flush the per-instance cast metadata caches.

Return Value

void

in HasAttributes at line 815
protected array ensureCastsAreStringValues(array $casts)

Ensure that the given casts are strings.

Parameters

array $casts

Return Value

array

Exceptions

InvalidArgumentException

in HasAttributes at line 847
protected mixed castAttribute(string $key, mixed $value)

Cast an attribute to a native PHP type.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 915
protected mixed getClassCastableAttributeValue(string $key, mixed $value)

Cast the given attribute using a custom cast class.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 945
protected mixed getEnumCastableAttributeValue(string $key, mixed $value)

Cast the given attribute to an enum.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 963
protected string getCastType(string $key)

Get the type of cast for a model attribute.

Parameters

string $key

Return Value

string

in HasAttributes at line 997
protected mixed deviateClassCastableAttribute(string $method, string $key, mixed $value)

Increment or decrement the given attribute using the custom cast class.

Parameters

string $method
string $key
mixed $value

Return Value

mixed

in HasAttributes at line 1010
protected mixed serializeClassCastableAttribute(string $key, mixed $value)

Serialize the given attribute using the custom cast class.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 1023
protected bool compareClassCastableAttribute(string $key, mixed $original, mixed $value)

Compare two values for the given attribute using the custom cast class.

Parameters

string $key
mixed $original
mixed $value

Return Value

bool

in HasAttributes at line 1036
protected bool isCustomDateTimeCast(string $cast)

Determine if the cast type is a custom date time cast.

Parameters

string $cast

Return Value

bool

in HasAttributes at line 1045
protected bool isImmutableCustomDateTimeCast(string $cast)

Determine if the cast type is an immutable custom date time cast.

Parameters

string $cast

Return Value

bool

in HasAttributes at line 1054
protected bool isDecimalCast(string $cast)

Determine if the cast type is a decimal cast.

Parameters

string $cast

Return Value

bool

in HasAttributes at line 1062
protected void ensureValidDecimalScale(string $cast, string $attribute)

Ensure the decimal cast has a valid scale.

Parameters

string $cast
string $attribute

Return Value

void

in HasAttributes at line 1076
mixed setAttribute(string|int $key, mixed $value)

Set a given attribute on the model.

Parameters

string|int $key
mixed $value

Return Value

mixed

in HasAttributes at line 1147
bool hasSetMutator(string $key)

Determine if a set mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1155
bool hasAttributeSetMutator(string $key)

Determine if an "Attribute" return type marked set mutator exists for an attribute.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1178
protected mixed setMutatedAttributeValue(string $key, mixed $value)

Set the value of an attribute using its mutator.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 1194
protected mixed setAttributeMarkedMutatedAttributeValue(string $key, mixed $value)

Set the value of a "Attribute" return type marked attribute using its mutator.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 1223
protected bool isDateAttribute(string $key)

Determine if the given attribute is a date or date castable.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1234
HasAttributes fillJsonAttribute(string $key, mixed $value)

Set a given JSON attribute on the model.

Parameters

string $key
mixed $value

Return Value

HasAttributes

in HasAttributes at line 1264
protected void setClassCastableAttribute(string $key, mixed $value)

Set the value of a class castable attribute.

Parameters

string $key
mixed $value

Return Value

void

in HasAttributes at line 1293
protected void setEnumCastableAttribute(string $key, mixed $value)

Set the value of an enum castable attribute.

Parameters

string $key
mixed $value

Return Value

void

in HasAttributes at line 1316
protected mixed getEnumCaseFromValue(string $enumClass, string|int $value)

Get an enum case instance from a given class and value.

Parameters

string $enumClass
string|int $value

Return Value

mixed

in HasAttributes at line 1330
protected string|int getStorableEnumValue(string $expectedEnum, mixed $value)

Get the storable value from the given enum.

Parameters

string $expectedEnum
mixed $value

Return Value

string|int

Exceptions

ValueError

in HasAttributes at line 1342
protected array getArrayAttributeWithValue(string $path, string $key, mixed $value)

Get an array attribute with the given key and value set.

Parameters

string $path
string $key
mixed $value

Return Value

array

in HasAttributes at line 1352
protected array getArrayAttributeByKey(string $key)

Get an array attribute or return an empty array if it is not set.

Parameters

string $key

Return Value

array

in HasAttributes at line 1370
protected string castAttributeAsJson(string $key, mixed $value)

Cast the given attribute to JSON.

Parameters

string $key
mixed $value

Return Value

string

Exceptions

JsonEncodingException

in HasAttributes at line 1388
protected int getJsonCastFlags(string $key)

Get the JSON casting flags for the given attribute.

Parameters

string $key

Return Value

int

in HasAttributes at line 1402
protected string|false asJson(mixed $value, int $flags = 0)

Encode the given value as JSON.

Parameters

mixed $value
int $flags

Return Value

string|false

in HasAttributes at line 1410
mixed fromJson(string|int|float|null $value, bool $asObject = false)

Decode the given JSON back into an array or object.

Parameters

string|int|float|null $value
bool $asObject

Return Value

mixed

in HasAttributes at line 1422
mixed fromEncryptedString(string $value)

Decrypt the given encrypted string.

Parameters

string $value

Return Value

mixed

in HasAttributes at line 1430
protected string castAttributeAsEncryptedString(string $key, mixed $value)

Cast the given attribute to an encrypted string.

Parameters

string $key
mixed $value

Return Value

string

in HasAttributes at line 1441
static void encryptUsing(Encrypter|null $encrypter)

Set the encrypter instance that will be used to encrypt attributes.

The encrypter persists in a static property for the worker lifetime and is used by primitive encrypted casts across all coroutines.

Parameters

Encrypter|null $encrypter

Return Value

void

in HasAttributes at line 1450
static Encrypter currentEncrypter()

Get the current encrypter being used by the model.

Return Value

Encrypter

in HasAttributes at line 1460
protected string|null castAttributeAsHashedString(string $key, mixed $value)

Cast the given attribute to a hashed string.

Parameters

string $key
mixed $value

Return Value

string|null

Exceptions

RuntimeException

in HasAttributes at line 1480
float fromFloat(mixed $value)

Decode the given float.

Parameters

mixed $value

Return Value

float

in HasAttributes at line 1500
protected string asDecimal(float|int|string $value, int $decimals)

Return a decimal as string.

Parameters

float|int|string $value
int $decimals

Return Value

string

Exceptions

MathException

in HasAttributes at line 1520
protected CarbonInterface asDate(mixed $value)

Return a timestamp as DateTime object with time set to 00:00:00.

Parameters

mixed $value

Return Value

CarbonInterface

in HasAttributes at line 1528
protected CarbonInterface asDateTime(mixed $value)

Return a timestamp as DateTime object.

Parameters

mixed $value

Return Value

CarbonInterface

in HasAttributes at line 1578
protected bool isStandardDateFormat(string $value)

Determine if the given value is a standard date format.

Parameters

string $value

Return Value

bool

in HasAttributes at line 1586
string|null fromDateTime(mixed $value)

Convert a DateTime to a storable string.

Parameters

mixed $value

Return Value

string|null

in HasAttributes at line 1596
protected int asTimestamp(mixed $value)

Return a timestamp as unix timestamp.

Parameters

mixed $value

Return Value

int

in HasAttributes at line 1604
protected string serializeDate(DateTimeInterface $date)

Prepare a date for array / JSON serialization.

Parameters

DateTimeInterface $date

Return Value

string

in HasAttributes at line 1617
array getDates()

Get the attributes that should be converted to dates.

Return Value

array

in HasAttributes at line 1628
string getDateFormat()

Get the format for database stored dates.

Return Value

string

in HasAttributes at line 1638
HasAttributes setDateFormat(string $format)

Set the date format used by the model.

Parameters

string $format

Return Value

HasAttributes

in HasAttributes at line 1648
bool hasCast(string $key, array|string|null $types = null)

Determine whether an attribute should be cast to a native type.

Parameters

string $key
array|string|null $types

Return Value

bool

in HasAttributes at line 1662
array getCasts()

Get the attributes that should be cast.

Return Value

array

in HasAttributes at line 1679
protected array casts()

Get the attributes that should be cast.

Return Value

array

in HasAttributes at line 1689
protected array defaults()

Get the default attribute values for the model.

Return Value

array

in HasAttributes at line 1697
protected void mergeDefaultAttributes()

Merge the default values into the model's attributes.

Return Value

void

in HasAttributes at line 1705
protected bool isDateCastable(string $key)

Determine whether a value is Date / DateTime castable for inbound manipulation.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1713
protected bool isDateCastableWithCustomFormat(string $key)

Determine whether a value is Date / DateTime custom-castable for inbound manipulation.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1721
protected bool isJsonCastable(string $key)

Determine whether a value is JSON castable for inbound manipulation.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1729
protected bool isEncryptedCastable(string $key)

Determine whether a value is an encrypted castable for inbound manipulation.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1737
protected bool isEncryptedClassCastable(string $key)

Determine whether a value is an encrypted class castable for inbound manipulation.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1748
protected bool isClassCastable(string $key)

Determine if the given key is cast using a custom class.

Parameters

string $key

Return Value

bool

Exceptions

InvalidCastException

in HasAttributes at line 1778
protected bool isEnumCastable(string $key)

Determine if the given key is cast using an enum.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1808
protected bool isClassDeviable(string $key)

Determine if the key is deviable using a custom class.

Parameters

string $key

Return Value

bool

Exceptions

InvalidCastException

in HasAttributes at line 1828
protected bool isClassSerializable(string $key)

Determine if the key is serializable using a custom class.

Parameters

string $key

Return Value

bool

Exceptions

InvalidCastException

in HasAttributes at line 1838
protected bool isClassComparable(string $key)

Determine if the key is comparable using a custom class.

Parameters

string $key

Return Value

bool

in HasAttributes at line 1848
protected mixed resolveCasterClass(string $key)

Resolve the custom caster class for a given key.

Parameters

string $key

Return Value

mixed

in HasAttributes at line 1884
static void flushCasterCache()

Flush the caster cache for the model.

Clears the worker-wide caster instance cache shared by every coroutine; next attribute access rebuilds the casters.

Return Value

void

in HasAttributes at line 1892
protected string parseCasterClass(string $class)

Parse the given caster class, removing any arguments.

Parameters

string $class

Return Value

string

in HasAttributes at line 1902
protected void mergeAttributesFromCachedCasts()

Merge the cast class and attribute cast attributes back into the model.

Return Value

void

in HasAttributes at line 1911
protected void mergeAttributeFromCachedCasts(string $key)

Merge the cast class and attribute cast attribute back into the model.

Parameters

string $key

Return Value

void

in HasAttributes at line 1920
protected void mergeAttributesFromClassCasts()

Merge the cast class attributes back into the model.

Return Value

void

in HasAttributes at line 1930
protected void mergeAttributeFromClassCasts(string $key)

Merge the cast class attribute back into the model.

Parameters

string $key

Return Value

void

in HasAttributes at line 1951
protected void mergeAttributesFromAttributeCasts()

Merge the cast class attributes back into the model.

Return Value

void

in HasAttributes at line 1961
protected void mergeAttributeFromAttributeCasts(string $key)

Merge the cast class attribute back into the model.

Parameters

string $key

Return Value

void

in HasAttributes at line 1995
protected bool mergeCachedCastAttributes(array $attributes, array $storedValues)

Merge cached cast values, advance their baseline, and indicate whether stored replacements took precedence.

Parameters

array $attributes
array $storedValues

Return Value

bool

in HasAttributes at line 2027
protected array normalizeCastClassResponse(string $key, mixed $value)

Normalize the response from a custom class caster.

Parameters

string $key
mixed $value

Return Value

array

in HasAttributes at line 2037
array getAttributes()

Get all of the current attributes on the model.

Return Value

array

in HasAttributes at line 2047
protected array getAttributesForInsert()

Get all of the current attributes on the model for an insert operation.

Return Value

array

in HasAttributes at line 2067
array prepareBinaryAttributesForDatabase(array $attributes)

Wrap raw binary attribute bytes or streams for database binding.

Parameters

array $attributes

Return Value

array

in HasAttributes at line 2091
mixed encodeBinaryAttributeForDatabase(string $key, mixed $value)

Encode a binary attribute's cast value, such as a UUID string, for database binding.

Preserve explicit binary parameters and raw streams without encoding them again.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 2111
HasAttributes setRawAttributes(array $attributes, bool $sync = false)

Set the array of model attributes. No checking is done.

Parameters

array $attributes
bool $sync

Return Value

HasAttributes

in HasAttributes at line 2133
mixed getOriginal(string|null $key = null, mixed $default = null)

Get the model's original attribute values.

Parameters

string|null $key
mixed $default

Return Value

mixed

in HasAttributes at line 2146
protected mixed getOriginalWithoutRewindingModel(string|null $key = null, mixed $default = null)

Get the model's original attribute values.

Parameters

string|null $key
mixed $default

Return Value

mixed

in HasAttributes at line 2165
mixed getRawOriginal(string|null $key = null, mixed $default = null)

Get the model's raw original attribute values.

Parameters

string|null $key
mixed $default

Return Value

mixed

in HasAttributes at line 2176
array only(mixed $attributes)

Get a subset of the model's attributes.

Parameters

mixed $attributes

Return Value

array

in HasAttributes at line 2192
array except(mixed $attributes)

Get all attributes except the given ones.

Parameters

mixed $attributes

Return Value

array

in HasAttributes at line 2212
HasAttributes syncOriginal()

Sync the original attributes with the current.

Return Value

HasAttributes

in HasAttributes at line 2224
HasAttributes syncOriginalAttribute(string $attribute)

Sync a single original attribute with its current value.

Parameters

string $attribute

Return Value

HasAttributes

in HasAttributes at line 2235
HasAttributes syncOriginalAttributes(array|string $attributes)

Sync multiple original attribute with their current values.

Parameters

array|string $attributes

Return Value

HasAttributes

in HasAttributes at line 2253
HasAttributes syncChanges()

Sync the changed attributes.

Return Value

HasAttributes

in HasAttributes at line 2287
bool isDirty(array|string|null $attributes = null)

Determine if the model or any of the given attribute(s) have been modified.

Parameters

array|string|null $attributes

Return Value

bool

in HasAttributes at line 2300
bool isClean(array|string|null $attributes = null)

Determine if the model or all the given attribute(s) have remained the same.

Parameters

array|string|null $attributes

Return Value

bool

in HasAttributes at line 2310
HasAttributes discardChanges()

Discard attribute changes and reset the attributes to their original state.

Return Value

HasAttributes

in HasAttributes at line 2327
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.

Parameters

array|string|null $attributes

Return Value

bool

in HasAttributes at line 2341
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.

Parameters

array $changes
array|string|null $attributes

Return Value

bool

in HasAttributes at line 2367
array getDirty()

Get the attributes that have been changed since the last sync.

Return Value

array

in HasAttributes at line 2399
protected array getDirtyForUpdate()

Get the attributes that have been changed since the last sync for an update operation.

Return Value

array

in HasAttributes at line 2409
array getChanges()

Get the attributes that were changed when the model was last saved.

Return Value

array

in HasAttributes at line 2419
array getPrevious()

Get the attributes that were previously original before the model was last saved.

Return Value

array

in HasAttributes at line 2427
bool originalIsEquivalent(string $key)

Determine if the new and old values for a given key are equivalent.

Parameters

string $key

Return Value

bool

in HasAttributes at line 2518
protected bool jsonIsEquivalent(string|int|float|null $attribute, string|int|float|null $original, bool $asObject)

Compare JSON values using the structure exposed by their cast.

Parameters

string|int|float|null $attribute
string|int|float|null $original
bool $asObject

Return Value

bool

in HasAttributes at line 2535
protected mixed transformModelValue(string $key, mixed $value)

Transform a raw model value using mutators, casts, etc.

Parameters

string $key
mixed $value

Return Value

mixed

in HasAttributes at line 2578
HasAttributes append(array|string $attributes)

Append attributes to query when building a query.

Parameters

array|string $attributes

Return Value

HasAttributes

in HasAttributes at line 2592
array getAppends()

Get the accessors that are being appended to model arrays.

Return Value

array

in HasAttributes at line 2603
HasAttributes setAppends(array $appends)

Set the accessors to append to model arrays.

Parameters

array $appends

Return Value

HasAttributes

in HasAttributes at line 2616
HasAttributes mergeAppends(array $appends)

Merge new appended attributes with existing appended attributes on the model.

Parameters

array $appends

Return Value

HasAttributes

in HasAttributes at line 2630
bool hasAppended(string $attribute)

Return whether the accessor attribute has been appended.

Parameters

string $attribute

Return Value

bool

in HasAttributes at line 2640
HasAttributes withoutAppends()

Remove all appended properties from the model.

Return Value

HasAttributes

in HasAttributes at line 2650
array getMutatedAttributes()

Get the mutated attributes for a given instance.

Return Value

array

in HasAttributes at line 2662
static void cacheMutatedAttributes(object|string $classOrInstance)

Extract and cache all the mutated attributes of a class.

Parameters

object|string $classOrInstance

Return Value

void

in HasAttributes at line 2681
static protected array getMutatorMethods(mixed $class)

Get all of the attribute mutator methods.

Parameters

mixed $class

Return Value

array

in HasAttributes at line 2691
static protected array getAttributeMarkedMutatorMethods(mixed $class)

Get all of the "Attribute" return typed attribute mutator methods.

Parameters

mixed $class

Return Value

array

in HasEvents at line 44
static void bootHasEvents()

Boot the has event trait for a model.

Return Value

void

in HasEvents at line 60
static array resolveObserveAttributes()

Resolve the observe class names from the attributes.

Return Value

array

in HasEvents at line 89
static void observe(object|array|string $classes)

Register observers with the model.

Observer listeners are registered on the worker-wide event dispatcher and persist for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

object|array|string $classes

Return Value

void

Exceptions

InvalidArgumentException

in HasEvents at line 110
protected void registerObserver(object|string $class)

Register a single observer with the model.

Observer listeners persist on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

object|string $class

Return Value

void

Exceptions

InvalidArgumentException

in HasEvents at line 151
array getObservableEvents()

Get the observable event names.

Return Value

array

in HasEvents at line 169
HasEvents setObservableEvents(array $observables)

Set the observable event names.

Parameters

array $observables

Return Value

HasEvents

in HasEvents at line 181
void addObservableEvents(array|string $observables)

Add an observable event name.

Parameters

array|string $observables

Return Value

void

in HasEvents at line 194
void removeObservableEvents(array|string $observables)

Remove an observable event name.

Parameters

array|string $observables

Return Value

void

in HasEvents at line 210
static protected void registerModelEvent(string $event, mixed $callback)

Register a model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

string $event
mixed $callback

Return Value

void

in HasEvents at line 223
protected mixed fireModelEvent(string $event, bool $halt = true)

Fire the given event for the model.

Parameters

string $event
bool $halt

Return Value

mixed

in HasEvents at line 253
protected mixed fireCustomModelEvent(string $event, string $method)

Fire a custom model event for the given event.

Parameters

string $event
string $method

Return Value

mixed

in HasEvents at line 271
protected mixed filterModelEventResults(mixed $result)

Filter the model event results.

Parameters

mixed $result

Return Value

mixed

in HasEvents at line 288
static void retrieved(mixed $callback)

Register a retrieved model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 302
static void saving(mixed $callback)

Register a saving model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 316
static void saved(mixed $callback)

Register a saved model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 330
static void updating(mixed $callback)

Register an updating model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 344
static void updated(mixed $callback)

Register an updated model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 358
static void creating(mixed $callback)

Register a creating model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 372
static void created(mixed $callback)

Register a created model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 386
static void replicating(mixed $callback)

Register a replicating model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 400
static void deleting(mixed $callback)

Register a deleting model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 414
static void deleted(mixed $callback)

Register a deleted model event with the dispatcher.

Listener persists on the worker-wide event dispatcher for the worker lifetime; runtime use leaks listeners across every subsequent request.

Parameters

mixed $callback

Return Value

void

in HasEvents at line 426
static void flushEventListeners()

Remove all the event listeners for the model.

Removes listeners from the worker-wide event dispatcher; concurrent coroutines lose model events mid-request.

Return Value

void

in HasEvents at line 449
array dispatchesEvents()

Get the event map for the model.

Return Value

array

in HasEvents at line 460
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.

Return Value

Dispatcher|null

in HasEvents at line 475
static void setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

The dispatcher persists in a static property for the worker lifetime and is used by every model event firing across all coroutines.

Parameters

Dispatcher $dispatcher

Return Value

void

in HasEvents at line 487
static void unsetEventDispatcher()

Unset the event dispatcher for models.

Clears the worker-wide event dispatcher shared by every coroutine; concurrent model operations will not fire events.

Return Value

void

in HasEvents at line 504
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.

Parameters

callable $callback

Return Value

mixed

in HasEvents at line 519
static bool eventsDisabled()

Determine if model events are currently disabled for this coroutine.

Return Value

bool

in HasGlobalScopes at line 25
static void bootHasGlobalScopes()

Boot the has global scopes trait for a model.

Return Value

void

in HasGlobalScopes at line 33
static array resolveGlobalScopeAttributes()

Resolve the global scope class names from the attributes.

Return Value

array

in HasGlobalScopes at line 67
static mixed addGlobalScope(Scope|Closure|string $scope, Scope|Closure|null $implementation = null)

Register a new global scope on the model.

The scope persists in a static property for the worker lifetime and applies to every query for this model class across all coroutines.

Parameters

Scope|Closure|string $scope
Scope|Closure|null $implementation

Return Value

mixed

Exceptions

InvalidArgumentException

in HasGlobalScopes at line 92
static void addGlobalScopes(array $scopes)

Register multiple global scopes on the model.

Delegates to addGlobalScope() per entry; each scope persists in a static property for the worker lifetime.

Parameters

array $scopes

Return Value

void

in HasGlobalScopes at line 107
static bool hasGlobalScope(Scope|int|string $scope)

Determine if a model has a global scope.

Parameters

Scope|int|string $scope

Return Value

bool

in HasGlobalScopes at line 117
static Scope|Closure|null getGlobalScope(Scope|int|string $scope)

Get a global scope registered with the model.

Parameters

Scope|int|string $scope

Return Value

Scope|Closure|null

in HasGlobalScopes at line 129
static array getAllGlobalScopes()

Get all of the global scopes that are currently registered.

Return Value

array

in HasGlobalScopes at line 141
static void setAllGlobalScopes(array $scopes)

Set the current global scopes.

Replaces the worker-wide global scopes registry shared by every coroutine; per-request use changes scope behavior for every concurrent model query.

Parameters

array $scopes

Return Value

void

in HasGlobalScopes at line 150
array getGlobalScopes()

Get the global scopes for this class instance.

Return Value

array

in HasRelationships at line 73
void initializeHasRelationships()

Initialize the HasRelationships trait.

Return Value

void

in HasRelationships at line 92
Closure|null relationResolver(string $class, string $key)

Get the dynamic relation resolver if defined or inherited, or return null.

Parameters

string $class
string $key

Return Value

Closure|null

in HasRelationships at line 112
static void resolveRelationUsing(string $name, Closure $callback)

Define a dynamic relation resolver.

The resolver persists in a static property for the worker lifetime and runs on every relation resolution for this model class across all coroutines.

Parameters

string $name
Closure $callback

Return Value

void

in HasRelationships at line 124
bool hasRelationAutoloadCallback()

Determine if a relationship autoloader callback has been defined.

Return Value

bool

in HasRelationships at line 134
HasRelationships autoloadRelationsUsing(Closure $callback, mixed $context = null)

Define an automatic relationship autoloader callback for this model and its relations.

Parameters

Closure $callback
mixed $context

Return Value

HasRelationships

in HasRelationships at line 154
protected bool attemptToAutoloadRelation(string $key)

Attempt to autoload the given relationship using the autoload callback.

Parameters

string $key

Return Value

bool

in HasRelationships at line 168
protected void invokeRelationAutoloadCallbackFor(string $key, array $tuples)

Invoke the relationship autoloader callback for the given relationships.

Parameters

string $key
array $tuples

Return Value

void

in HasRelationships at line 178
protected void propagateRelationAutoloadCallbackToRelation(string $key, mixed $models)

Propagate the relationship autoloader callback to the given related models.

Parameters

string $key
mixed $models

Return Value

void

in HasRelationships at line 207
HasOne hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null)

Define a one-to-one relationship.

Parameters

string $related
string|null $foreignKey
string|null $localKey

Return Value

HasOne

in HasRelationships at line 228
protected HasOne newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)

Instantiate a new HasOne relationship.

Parameters

Builder $query
Model $parent
string $foreignKey
string $localKey

Return Value

HasOne

in HasRelationships at line 243
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.

Parameters

string $related
string $through
string|null $firstKey
string|null $secondKey
string|null $localKey
string|null $secondLocalKey

Return Value

HasOneThrough

in HasRelationships at line 274
protected HasOneThrough newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)

Instantiate a new HasOneThrough relationship.

Parameters

Builder $query
Model $farParent
Model $throughParent
string $firstKey
string $secondKey
string $localKey
string $secondLocalKey

Return Value

HasOneThrough

in HasRelationships at line 287
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.

Parameters

string $related
string $name
string|null $type
string|null $id
string|null $localKey

Return Value

MorphOne

in HasRelationships at line 308
protected MorphOne newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)

Instantiate a new MorphOne relationship.

Parameters

Builder $query
Model $parent
string $type
string $id
string $localKey

Return Value

MorphOne

in HasRelationships at line 321
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.

Parameters

string $related
string|null $foreignKey
string|null $ownerKey
string|null $relation

Return Value

BelongsTo

in HasRelationships at line 363
protected BelongsTo newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)

Instantiate a new BelongsTo relationship.

Parameters

Builder $query
Model $child
string $foreignKey
string $ownerKey
string $relation

Return Value

BelongsTo

in HasRelationships at line 373
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.

Parameters

string|null $name
string|null $type
string|null $id
string|null $ownerKey

Return Value

MorphTo

in HasRelationships at line 399
protected MorphTo morphEagerTo(string $name, string $type, string $id, string|null $ownerKey)

Define a polymorphic, inverse one-to-one or many relationship.

Parameters

string $name
string $type
string $id
string|null $ownerKey

Return Value

MorphTo

in HasRelationships at line 417
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.

Parameters

string|int $target
string $name
string $type
string $id
string|null $ownerKey

Return Value

MorphTo

in HasRelationships at line 446
protected MorphTo newMorphTo(Builder $query, Model $parent, string $foreignKey, string|null $ownerKey, string $type, string $relation)

Instantiate a new MorphTo relationship.

Parameters

Builder $query
Model $parent
string $foreignKey
string|null $ownerKey
string $type
string $relation

Return Value

MorphTo

in HasRelationships at line 456
static string getActualClassNameForMorph(string|int $class)

Retrieve the actual class name for a given morph class.

Parameters

string|int $class

Return Value

string

Exceptions

ClassMorphViolationException

in HasRelationships at line 474
protected string guessBelongsToRelation()

Guess the "belongs to" relationship name.

Return Value

string

in HasRelationships at line 494
PendingHasThroughRelationship through(string|HasOneOrMany $relationship)

Create a pending has-many-through or has-one-through relationship.

Parameters

string|HasOneOrMany $relationship

Return Value

PendingHasThroughRelationship

in HasRelationships at line 512
HasMany hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null)

Define a one-to-many relationship.

Parameters

string $related
string|null $foreignKey
string|null $localKey

Return Value

HasMany

in HasRelationships at line 538
protected HasMany newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)

Instantiate a new HasMany relationship.

Parameters

Builder $query
Model $parent
string $foreignKey
string $localKey

Return Value

HasMany

in HasRelationships at line 553
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.

Parameters

string $related
string $through
string|null $firstKey
string|null $secondKey
string|null $localKey
string|null $secondLocalKey

Return Value

HasManyThrough

in HasRelationships at line 584
protected HasManyThrough newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)

Instantiate a new HasManyThrough relationship.

Parameters

Builder $query
Model $farParent
Model $throughParent
string $firstKey
string $secondKey
string $localKey
string $secondLocalKey

Return Value

HasManyThrough

in HasRelationships at line 597
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.

Parameters

string $related
string $name
string|null $type
string|null $id
string|null $localKey

Return Value

MorphMany

in HasRelationships at line 621
protected MorphMany newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)

Instantiate a new MorphMany relationship.

Parameters

Builder $query
Model $parent
string $type
string $id
string $localKey

Return Value

MorphMany

in HasRelationships at line 637
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.

Parameters

string $related
string|null $table
string|null $foreignPivotKey
string|null $relatedPivotKey
string|null $parentKey
string|null $relatedKey
string|null $relation

Return Value

BelongsToMany

in HasRelationships at line 696
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.

Parameters

Builder $query
Model $parent
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey
string|null $relationName

Return Value

BelongsToMany

in HasRelationships at line 717
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.

Parameters

string $related
string $name
string|null $table
string|null $foreignPivotKey
string|null $relatedPivotKey
string|null $parentKey
string|null $relatedKey
string|null $relation
bool $inverse

Return Value

MorphToMany

in HasRelationships at line 774
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.

Parameters

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

Return Value

MorphToMany

in HasRelationships at line 808
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.

Parameters

string $related
string $name
string|null $table
string|null $foreignPivotKey
string|null $relatedPivotKey
string|null $parentKey
string|null $relatedKey
string|null $relation

Return Value

MorphToMany

in HasRelationships at line 841
protected string|null guessBelongsToManyRelation()

Get the relationship name of the belongsToMany relationship.

Return Value

string|null

in HasRelationships at line 857
string joiningTable(string $related, Model|null $instance = null)

Get the joining table name for a many-to-many relation.

Parameters

string $related
Model|null $instance

Return Value

string

in HasRelationships at line 880
string joiningTableSegment()

Get this model's half of the intermediate table name for belongsToMany relationships.

Return Value

string

in HasRelationships at line 888
bool touches(string $relation)

Determine if the model touches a given relation.

Parameters

string $relation

Return Value

bool

in HasRelationships at line 896
void touchOwners()

Touch the owning relations of the model.

Return Value

void

in HasRelationships at line 918
protected array getMorphs(string $name, string|null $type, string|null $id)

Get the polymorphic relationship columns.

Parameters

string $name
string|null $type
string|null $id

Return Value

array

in HasRelationships at line 928
string getMorphClass()

Get the class name for polymorphic relations.

Return Value

string

Exceptions

ClassMorphViolationException

in HasRelationships at line 956
protected Model newRelatedInstance(string $class)

Create a new model instance for a related model.

Parameters

string $class

Return Value

Model

in HasRelationships at line 973
protected Model newRelatedThroughInstance(string $class)

Create a new model instance for a related "through" model.

Parameters

string $class

Return Value

Model

in HasRelationships at line 981
array getRelations()

Get all the loaded relations for the instance.

Return Value

array

in HasRelationships at line 989
mixed getRelation(string $relation)

Get a specified relationship.

Parameters

string $relation

Return Value

mixed

in HasRelationships at line 997
bool relationLoaded(string $key)

Determine if the given relation is loaded.

Parameters

string $key

Return Value

bool

in HasRelationships at line 1007
HasRelationships setRelation(string $relation, mixed $value)

Set the given relationship on the model.

Parameters

string $relation
mixed $value

Return Value

HasRelationships

in HasRelationships at line 1021
HasRelationships unsetRelation(string $relation)

Unset a loaded relationship.

Parameters

string $relation

Return Value

HasRelationships

in HasRelationships at line 1033
HasRelationships setRelations(array $relations)

Set the entire relations array on the model.

Parameters

array $relations

Return Value

HasRelationships

in HasRelationships at line 1045
HasRelationships withRelationshipAutoloading()

Enable relationship autoloading for this model.

Return Value

HasRelationships

in HasRelationships at line 1055
HasRelationships withoutRelations()

Duplicate the instance and unset all the loaded relations.

Return Value

HasRelationships

in HasRelationships at line 1065
HasRelationships withoutRelation(array|string $relations)

Duplicate the instance and unset the given loaded relations.

Parameters

array|string $relations

Return Value

HasRelationships

in HasRelationships at line 1081
HasRelationships unsetRelations()

Unset all the loaded relations for the instance.

Return Value

HasRelationships

in HasRelationships at line 1093
array getTouchedRelations()

Get the relationships that are touched on save.

Return Value

array

in HasRelationships at line 1104
HasRelationships setTouchedRelations(array $touches)

Set the relationships that are touched on save.

Parameters

array $touches

Return Value

HasRelationships

in HasTimestamps at line 30
void initializeHasTimestamps()

Initialize the HasTimestamps trait.

Return Value

void

in HasTimestamps at line 54
bool touch(array|string|null $attribute = null)

Update the model's update timestamp.

Parameters

array|string|null $attribute

Return Value

bool

in HasTimestamps at line 78
bool touchQuietly(array|string|null $attribute = null)

Update the model's update timestamp without raising any events.

Parameters

array|string|null $attribute

Return Value

bool

in HasTimestamps at line 88
HasTimestamps updateTimestamps()

Update the creation and update timestamps.

Return Value

HasTimestamps

in HasTimestamps at line 112
HasTimestamps setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

Parameters

mixed $value

Return Value

HasTimestamps

in HasTimestamps at line 124
HasTimestamps setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

Parameters

mixed $value

Return Value

HasTimestamps

in HasTimestamps at line 134
CarbonInterface freshTimestamp()

Get a fresh timestamp for the model.

Return Value

CarbonInterface

in HasTimestamps at line 142
string freshTimestampString()

Get a fresh timestamp for the model.

Return Value

string

in HasTimestamps at line 150
bool usesTimestamps()

Determine if the model uses timestamps.

Return Value

bool

in HasTimestamps at line 158
string|null getCreatedAtColumn()

Get the name of the "created at" column.

Return Value

string|null

in HasTimestamps at line 166
string|null getUpdatedAtColumn()

Get the name of the "updated at" column.

Return Value

string|null

in HasTimestamps at line 174
string|null getQualifiedCreatedAtColumn()

Get the fully-qualified "created at" column.

Return Value

string|null

in HasTimestamps at line 184
string|null getQualifiedUpdatedAtColumn()

Get the fully-qualified "updated at" column.

Return Value

string|null

in HasTimestamps at line 199
static mixed withoutTimestamps(callable $callback)

Disable timestamps for the current class during the given callback scope.

Parameters

callable $callback

Return Value

mixed

in HasTimestamps at line 213
static mixed withoutTimestampsOn(array $models, callable $callback)

Disable timestamps for the given model classes during the given callback scope.

Parameters

array $models
callable $callback

Return Value

mixed

in HasTimestamps at line 231
static bool isIgnoringTimestamps(string|null $class = null)

Determine if the given model is ignoring timestamps / touches.

Parameters

string|null $class

Return Value

bool

in HasUniqueIds at line 17
bool usesUniqueIds()

Determine if the model uses unique ids.

Return Value

bool

in HasUniqueIds at line 25
void setUniqueIds()

Generate unique keys for the model.

Return Value

void

in HasUniqueIds at line 37
string|null newUniqueId()

Generate a new key for the model.

Return Value

string|null

in HasUniqueIds at line 47
array uniqueIds()

Get the columns that should receive a unique identifier.

Return Value

array

in HidesAttributes at line 31
void initializeHidesAttributes()

Initialize the HidesAttributes trait.

Return Value

void

in HidesAttributes at line 47
array getHidden()

Get the hidden attributes for the model.

Return Value

array

in HidesAttributes at line 58
HidesAttributes setHidden(array $hidden)

Set the hidden attributes for the model.

Parameters

array $hidden

Return Value

HidesAttributes

in HidesAttributes at line 71
HidesAttributes mergeHidden(array $hidden)

Merge new hidden attributes with existing hidden attributes on the model.

Parameters

array $hidden

Return Value

HidesAttributes

in HidesAttributes at line 87
array getVisible()

Get the visible attributes for the model.

Return Value

array

in HidesAttributes at line 98
HidesAttributes setVisible(array $visible)

Set the visible attributes for the model.

Parameters

array $visible

Return Value

HidesAttributes

in HidesAttributes at line 111
HidesAttributes mergeVisible(array $visible)

Merge new visible attributes with existing visible attributes on the model.

Parameters

array $visible

Return Value

HidesAttributes

in HidesAttributes at line 128
HidesAttributes makeVisible(array|string|null $attributes)

Make the given, typically hidden, attributes visible.

Parameters

array|string|null $attributes

Return Value

HidesAttributes

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.

Parameters

bool|Closure $condition
array|string|null $attributes

Return Value

HidesAttributes

in HidesAttributes at line 158
HidesAttributes makeHidden(array|string|null $attributes)

Make the given, typically visible, attributes hidden.

Parameters

array|string|null $attributes

Return Value

HidesAttributes

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.

Parameters

bool|Closure $condition
array|string|null $attributes

Return Value

HidesAttributes

in GuardsAttributes at line 48
void initializeGuardsAttributes()

Initialize the GuardsAttributes trait.

Return Value

void

in GuardsAttributes at line 72
static protected array guardConfiguration()

Resolve the nearest guard configuration for the model class.

Return Value

array

in GuardsAttributes at line 126
static protected array|null guardConfigurationFromTraits(array $traits)

Resolve guard configuration declared by traits at one class level.

Parameters

array $traits

Return Value

array|null

in GuardsAttributes at line 149
array getFillable()

Get the fillable attributes for the model.

Return Value

array

in GuardsAttributes at line 160
GuardsAttributes fillable(array $fillable)

Set the fillable attributes for the model.

Parameters

array $fillable

Return Value

GuardsAttributes

in GuardsAttributes at line 173
GuardsAttributes mergeFillable(array $fillable)

Merge new fillable attributes with existing fillable attributes on the model.

Parameters

array $fillable

Return Value

GuardsAttributes

in GuardsAttributes at line 189
array getGuarded()

Get the guarded attributes for the model.

Return Value

array

in GuardsAttributes at line 202
GuardsAttributes guard(array $guarded)

Set the guarded attributes for the model.

Parameters

array $guarded

Return Value

GuardsAttributes

in GuardsAttributes at line 215
GuardsAttributes mergeGuarded(array $guarded)

Merge new guarded attributes with existing guarded attributes on the model.

Parameters

array $guarded

Return Value

GuardsAttributes

in GuardsAttributes at line 227
static void unguard(bool $state = true)

Disable all mass assignable restrictions.

Uses Context for coroutine-safe state management.

Parameters

bool $state

Return Value

void

in GuardsAttributes at line 235
static void reguard()

Enable the mass assignment restrictions.

Return Value

void

in GuardsAttributes at line 243
static bool isUnguarded()

Determine if the current state is "unguarded".

Return Value

bool

in GuardsAttributes at line 259
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.

Parameters

callable $callback

Return Value

mixed

in GuardsAttributes at line 278
bool isFillable(string $key)

Determine if the given attribute may be mass assigned.

Parameters

string $key

Return Value

bool

in GuardsAttributes at line 306
bool isGuarded(string $key)

Determine if the given key is guarded.

Parameters

string $key

Return Value

bool

in GuardsAttributes at line 320
protected bool isGuardableColumn(string $key)

Determine if the given column is a valid, guardable column.

Parameters

string $key

Return Value

bool

in GuardsAttributes at line 344
bool totallyGuarded()

Determine if the model is totally guarded.

Return Value

bool

in GuardsAttributes at line 355
protected array fillableFromArray(array $attributes)

Get the fillable attributes of a given array.

Parameters

array $attributes

Return Value

array

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.

Parameters

callable $callback
mixed $default

Return Value

mixed

static protected void clearRecursiveCallValue(object $object, string $hash)

Remove an entry from the recursion cache for an object.

Parameters

object $object
string $hash

Return Value

void

static protected array getRecursiveCallStack(object $object)

Get the stack of methods being called recursively for the current object.

Parameters

object $object

Return Value

array

static protected WeakMap getRecursionCache()

Get the current recursion cache being used by the model.

Return Value

WeakMap

static protected mixed setRecursiveCallValue(object $object, string $hash, mixed $value)

Set a value in the recursion cache for the given object and method.

Parameters

object $object
string $hash
mixed $value

Return Value

mixed

JsonResource toResource(string|null $resourceClass = null)

Create a new resource object for the given resource.

Parameters

string|null $resourceClass

Return Value

JsonResource

protected JsonResource guessResource()

Guess the resource class for the model.

Return Value

JsonResource

Exceptions

LogicException

static array guessResourceName()

Guess the resource class name for the model.

Return Value

array

protected string|null resolveResourceFromAttribute(string $class)

Get the resource class from the UseResource attribute.

Parameters

string $class

Return Value

string|null

in ForwardsCalls at line 22
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

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.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 66
static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

in HasCollection at line 28
Collection newCollection(array $models = [])

Create a new Eloquent Collection instance.

Parameters

array $models

Return Value

Collection

in HasCollection at line 48
string|null resolveCollectionFromAttribute()

Resolve the collection class name from the CollectedBy attribute.

Return Value

string|null

in Model at line 390
__construct(array $attributes = [])

Create a new Eloquent model instance.

Parameters

array $attributes

in Model at line 413
protected void bootIfNotBooted()

Check if the model needs to be booted and if so, do it.

Return Value

void

Exceptions

LogicException
RuntimeException

in Model at line 482
static protected void booting()

Perform any actions required before the model boots.

Return Value

void

in Model at line 489
static protected void boot()

Bootstrap the model and its traits.

Return Value

void

in Model at line 497
static protected void bootTraits()

Boot all of the bootable traits on the model.

Return Value

void

in Model at line 532
protected void initializeTraits()

Initialize any initializable traits on the model.

Return Value

void

in Model at line 542
void initializeModelAttributes()

Initialize the model attributes from class attributes.

Return Value

void

in Model at line 587
static protected void booted()

Perform any actions required after the model boots.

Return Value

void

in Model at line 594
static protected void whenBooted(Closure $callback)

Register a closure to be executed after the model has booted.

Parameters

Closure $callback

Return Value

void

in Model at line 607
static void clearBootedModels()

Clear the list of booted models so they will be re-booted.

Clears worker-wide boot state, boot callbacks, and global scopes; concurrent coroutines mid-query may observe inconsistent model state.

Return Value

void

in Model at line 625
static void withoutTouching(callable $callback)

Disables relationship model touching for the current class during given callback scope.

Parameters

callable $callback

Return Value

void

in Model at line 635
static void withoutTouchingOn(array $models, callable $callback)

Disables relationship model touching for the given model classes during given callback scope.

Parameters

array $models
callable $callback

Return Value

void

in Model at line 653
static bool isIgnoringTouch(string|null $class = null)

Determine if the given model is ignoring touches.

Parameters

string|null $class

Return Value

bool

in Model at line 689
static void shouldBeStrict(bool $shouldBeStrict = true)

Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.

Toggles worker-wide strict-mode flags that apply to every model operation across all coroutines.

Parameters

bool $shouldBeStrict

Return Value

void

in Model at line 703
static void preventLazyLoading(bool $value = true)

Prevent model relationships from being lazy loaded.

The flag persists in a static property for the worker lifetime and applies to every relationship access across all coroutines.

Parameters

bool $value

Return Value

void

in Model at line 715
static void automaticallyEagerLoadRelationships(bool $value = true)

Determine if model relationships should be automatically eager loaded when accessed.

The flag persists in a static property for the worker lifetime and applies to every relationship access across all coroutines.

Parameters

bool $value

Return Value

void

in Model at line 731
static mixed withoutAutomaticallyEagerLoadingRelationships(callable $callback)

Execute a callback without automatically eager loading relationships for the models it retrieves or makes.

Uses Context, so concurrent coroutines keep the boot setting.

Parameters

callable $callback

Return Value

mixed

in Model at line 752
static void handleLazyLoadingViolationUsing(callable|null $callback)

Register a callback that is responsible for handling lazy loading violations.

The callback persists in a static property for the worker lifetime and runs on every lazy-loading violation across all coroutines.

Parameters

callable|null $callback

Return Value

void

in Model at line 764
static void preventSilentlyDiscardingAttributes(bool $value = true)

Prevent non-fillable attributes from being silently discarded.

The flag persists in a static property for the worker lifetime and applies to every mass assignment across all coroutines.

Parameters

bool $value

Return Value

void

in Model at line 779
static void handleDiscardedAttributeViolationUsing(callable|null $callback)

Register a callback that is responsible for handling discarded attribute violations.

The callback persists in a static property for the worker lifetime and runs on every discarded-attribute violation across all coroutines.

Parameters

callable|null $callback

Return Value

void

in Model at line 791
static void preventAccessingMissingAttributes(bool $value = true)

Prevent accessing missing attributes on retrieved models.

The flag persists in a static property for the worker lifetime and applies to every attribute access across all coroutines.

Parameters

bool $value

Return Value

void

in Model at line 805
static void handleMissingAttributeViolationUsing(callable|null $callback)

Register a callback that is responsible for handling missing attribute violations.

The callback persists in a static property for the worker lifetime and runs on every missing-attribute violation across all coroutines.

Parameters

callable|null $callback

Return Value

void

in Model at line 817
static void reportRouteModelBindingExceptions(bool $value = true)

Report invalid value exceptions during implicit route model binding.

The flag persists in a static property for the worker lifetime and applies to every implicit route binding across all coroutines.

Parameters

bool $value

Return Value

void

in Model at line 831
static mixed withoutBroadcasting(callable $callback)

Execute a callback without broadcasting any model events for all model types.

Parameters

callable $callback

Return Value

mixed

in Model at line 847
static bool isBroadcasting()

Determine if broadcasting is currently enabled.

Return Value

bool

in Model at line 860
Model fill(array $attributes)

Fill the model with an array of attributes.

Parameters

array $attributes

Return Value

Model

Exceptions

MassAssignmentException

in Model at line 913
Model forceFill(array $attributes)

Fill the model with an array of attributes. Force mass assignment.

Parameters

array $attributes

Return Value

Model

in Model at line 921
string qualifyColumn(string $column)

Qualify the given column name by the model's table.

Parameters

string $column

Return Value

string

in Model at line 936
array qualifyColumns(array $columns)

Qualify the given columns with the model's table.

Parameters

array $columns

Return Value

array

in Model at line 948
Model newInstance(array $attributes = [], bool $exists = false)

Create a new instance of the given model.

Parameters

array $attributes
bool $exists

Return Value

Model

in Model at line 975
Model newFromBuilder(array|object $attributes = [], UnitEnum|string|null $connection = null)

Create a new model instance that is existing.

Parameters

array|object $attributes
UnitEnum|string|null $connection

Return Value

Model

in Model at line 993
static Builder on(UnitEnum|string|null $connection = null)

Begin querying the model on a given connection.

Parameters

UnitEnum|string|null $connection

Return Value

Builder

in Model at line 1006
static Builder onWriteConnection()

Begin querying the model on the write connection.

Return Value

Builder

in Model at line 1017
static Collection all(array|string $columns = ['*'])

Get all of the models from the database.

Parameters

array|string $columns

Return Value

Collection

in Model at line 1030
static Builder with(array|string $relations)

Begin querying a model with eager loading.

Parameters

array|string $relations

Return Value

Builder

in Model at line 1043
Model load(array|string $relations)

Eager load relations on the model.

Parameters

array|string $relations

Return Value

Model

in Model at line 1060
Model loadMorph(string $relation, array $relations)

Eager load relationships on the polymorphic relation of a model.

Parameters

string $relation
array $relations

Return Value

Model

in Model at line 1079
Model loadMissing(array|string $relations)

Eager load relations on the model if they are not already eager loaded.

Parameters

array|string $relations

Return Value

Model

in Model at line 1094
Model loadAggregate(array|string $relations, Expression|string $column, string|null $function = null)

Eager load relation's column aggregations on the model.

Parameters

array|string $relations
Expression|string $column
string|null $function

Return Value

Model

in Model at line 1107
Model loadCount(array|string $relations)

Eager load relation counts on the model.

Parameters

array|string $relations

Return Value

Model

in Model at line 1120
Model loadMax(array|string $relations, Expression|string $column)

Eager load relation max column values on the model.

Parameters

array|string $relations
Expression|string $column

Return Value

Model

in Model at line 1131
Model loadMin(array|string $relations, Expression|string $column)

Eager load relation min column values on the model.

Parameters

array|string $relations
Expression|string $column

Return Value

Model

in Model at line 1142
Model loadSum(array|string $relations, Expression|string $column)

Eager load relation's column summations on the model.

Parameters

array|string $relations
Expression|string $column

Return Value

Model

in Model at line 1153
Model loadAvg(array|string $relations, Expression|string $column)

Eager load relation average column values on the model.

Parameters

array|string $relations
Expression|string $column

Return Value

Model

in Model at line 1164
Model loadExists(array|string $relations)

Eager load related model existence values on the model.

Parameters

array|string $relations

Return Value

Model

in Model at line 1175
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.

Parameters

string $relation
array $relations
Expression|string $column
string|null $function

Return Value

Model

in Model at line 1194
Model loadMorphCount(string $relation, array $relations)

Eager load relationship counts on the polymorphic relation of a model.

Parameters

string $relation
array $relations

Return Value

Model

in Model at line 1205
Model loadMorphMax(string $relation, array $relations, Expression|string $column)

Eager load relationship max column values on the polymorphic relation of a model.

Parameters

string $relation
array $relations
Expression|string $column

Return Value

Model

in Model at line 1216
Model loadMorphMin(string $relation, array $relations, Expression|string $column)

Eager load relationship min column values on the polymorphic relation of a model.

Parameters

string $relation
array $relations
Expression|string $column

Return Value

Model

in Model at line 1227
Model loadMorphSum(string $relation, array $relations, Expression|string $column)

Eager load relationship column summations on the polymorphic relation of a model.

Parameters

string $relation
array $relations
Expression|string $column

Return Value

Model

in Model at line 1238
Model loadMorphAvg(string $relation, array $relations, Expression|string $column)

Eager load relationship average column values on the polymorphic relation of a model.

Parameters

string $relation
array $relations
Expression|string $column

Return Value

Model

in Model at line 1248
protected int|false increment(string $column, mixed $amount = 1, array $extra = [])

Increment a column's value by a given amount.

Parameters

string $column
mixed $amount
array $extra

Return Value

int|false

in Model at line 1258
protected int|false decrement(string $column, mixed $amount = 1, array $extra = [])

Decrement a column's value by a given amount.

Parameters

string $column
mixed $amount
array $extra

Return Value

int|false

in Model at line 1268
protected int|false incrementOrDecrement(string $column, mixed $amount, array $extra, string $method)

Run the increment or decrement method on the model.

Parameters

string $column
mixed $amount
array $extra
string $method

Return Value

int|false

in Model at line 1320
bool update(array $attributes = [], array $options = [])

Update the model in the database.

Parameters

array $attributes
array $options

Return Value

bool

in Model at line 1337
bool updateOrFail(array $attributes = [], array $options = [])

Update the model in the database within a transaction.

Parameters

array $attributes
array $options

Return Value

bool

Exceptions

Throwable

in Model at line 1352
bool updateQuietly(array $attributes = [], array $options = [])

Update the model in the database without raising any events.

Parameters

array $attributes
array $options

Return Value

bool

in Model at line 1366
protected int incrementQuietly(string $column, float|int $amount = 1, array $extra = [])

Increment a column's value by a given amount without raising any events.

Parameters

string $column
float|int $amount
array $extra

Return Value

int

in Model at line 1379
protected int decrementQuietly(string $column, float|int $amount = 1, array $extra = [])

Decrement a column's value by a given amount without raising any events.

Parameters

string $column
float|int $amount
array $extra

Return Value

int

in Model at line 1393
protected int|false incrementEach(array $columns, array $extra = [])

Increment each given column's value by the given amounts.

Parameters

array $columns
array $extra

Return Value

int|false

in Model at line 1404
protected int|false decrementEach(array $columns, array $extra = [])

Decrement each given column's value by the given amounts.

Parameters

array $columns
array $extra

Return Value

int|false

in Model at line 1415
protected int incrementEachQuietly(array $columns, array $extra = [])

Increment each given column's value by the given amounts without raising any events.

Parameters

array $columns
array $extra

Return Value

int

in Model at line 1429
protected int decrementEachQuietly(array $columns, array $extra = [])

Decrement each given column's value by the given amounts without raising any events.

Parameters

array $columns
array $extra

Return Value

int

in Model at line 1443
protected int|false incrementOrDecrementEach(array $columns, array $extra, string $method)

Run the incrementEach or decrementEach method on the model.

Parameters

array $columns
array $extra
string $method

Return Value

int|false

in Model at line 1540
bool push()

Save the model and all of its relationships.

Return Value

bool

in Model at line 1569
bool pushQuietly()

Save the model and all of its relationships without raising any events to the parent model.

Return Value

bool

in Model at line 1579
bool saveQuietly(array $options = [])

Save the model to the database without raising any events.

Parameters

array $options

Return Value

bool

in Model at line 1589
bool save(array $options = [])

Save the model to the database.

Parameters

array $options

Return Value

bool

in Model at line 1638
bool saveOrIgnore(array $options = [], array|string|null $uniqueBy = null)

Save the model to the database, ignoring specific unique constraint conflicts.

Parameters

array $options
array|string|null $uniqueBy

Return Value

bool

Exceptions

LogicException

in Model at line 1672
bool saveOrFail(array $options = [])

Save the model to the database within a transaction.

Parameters

array $options

Return Value

bool

Exceptions

Throwable

in Model at line 1682
protected void finishSave(array $options)

Perform any actions that are necessary after the model is saved.

Parameters

array $options

Return Value

void

in Model at line 1698
protected bool performUpdate(Builder $query)

Perform a model update operation.

Parameters

Builder $query

Return Value

bool

in Model at line 1744
protected Builder setKeysForSelectQuery(Builder $query)

Set the keys for a select query.

Parameters

Builder $query

Return Value

Builder

in Model at line 1760
protected mixed getKeyForSelectQuery()

Get the primary key value for a select query.

Return Value

mixed

in Model at line 1771
protected Builder setKeysForSaveQuery(Builder $query)

Set the keys for a save update query.

Parameters

Builder $query

Return Value

Builder

in Model at line 1787
protected mixed getKeyForSaveQuery()

Get the primary key value for a save query.

Return Value

mixed

in Model at line 1821
protected bool performInsert(Builder $query)

Perform a model insert operation.

Parameters

Builder $query

Return Value

bool

in Model at line 1882
protected bool performInsertOrIgnore(Builder $query, array|string|null $uniqueBy)

Perform a model insert operation, ignoring specific unique constraint conflicts.

Parameters

Builder $query
array|string|null $uniqueBy

Return Value

bool

Exceptions

LogicException

in Model at line 1938
protected void insertAndSetId(Builder $query, array $attributes)

Insert the given attributes and set the ID on the model.

Parameters

Builder $query
array $attributes

Return Value

void

in Model at line 1950
protected void refreshSavedAttributes(array $attributes)

Refresh the configured attributes after the model is saved.

Parameters

array $attributes

the raw attribute values the write stored

Return Value

void

in Model at line 1978
static int destroy(Collection|Collection|array|int|string $ids)

Destroy the models for the given IDs.

Parameters

Collection|Collection|array|int|string $ids

Return Value

int

in Model at line 2017
int|bool|null delete()

Delete the model from the database.

Returns bool|null for standard models, int (affected rows) for pivot models.

Return Value

int|bool|null

Exceptions

LogicException

in Model at line 2054
int|bool|null deleteQuietly()

Delete the model from the database without raising any events.

Return Value

int|bool|null

in Model at line 2064
int|bool|null deleteOrFail()

Delete the model from the database within a transaction.

Return Value

int|bool|null

Exceptions

Throwable

in Model at line 2078
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.

Return Value

int|bool|null

in Model at line 2090
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.

Parameters

Collection|Collection|array|int|string $ids

Return Value

int

in Model at line 2098
protected void performDeleteOnModel()

Perform the actual delete query on this model instance.

Return Value

void

in Model at line 2110
static Builder query()

Begin querying the model.

Return Value

Builder

in Model at line 2120
Builder newQuery()

Get a new query builder for the model's table.

Return Value

Builder

in Model at line 2130
Builder newModelQuery()

Get a new query builder that doesn't have any global scopes or eager loading.

Return Value

Builder

in Model at line 2143
Builder newQueryWithoutRelationships()

Get a new query builder with no relationships loaded.

Return Value

Builder

in Model at line 2154
Builder registerGlobalScopes(Builder $builder)

Register the global scopes for this builder instance.

Parameters

Builder $builder

Return Value

Builder

in Model at line 2168
Builder newQueryWithoutScopes()

Get a new query builder that doesn't have any global scopes.

Return Value

Builder

in Model at line 2180
Builder newQueryWithoutScope(Scope|int|string $scope)

Get a new query instance without a given scope.

Parameters

Scope|int|string $scope

Return Value

Builder

in Model at line 2190
Builder newQueryForRestoration(array|int|string $ids)

Get a new query to restore one or more models by their queueable IDs.

Parameters

array|int|string $ids

Return Value

Builder

in Model at line 2200
Builder newEloquentBuilder(Builder $query)

Create a new Eloquent query builder for the model.

Parameters

Builder $query

Return Value

Builder

in Model at line 2217
protected string|false resolveCustomBuilderClass()

Resolve the custom Eloquent builder class from the model attributes.

Return Value

string|false

in Model at line 2225
protected Builder newBaseQueryBuilder()

Get a new query builder instance for the connection.

Return Value

Builder

in Model at line 2236
Model newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)

Create a new pivot model instance.

Parameters

Model $parent
array $attributes
string $table
bool $exists
string|null $using

Return Value

Model

in Model at line 2245
bool hasNamedScope(string $scope)

Determine if the model has a given scope.

Parameters

string $scope

Return Value

bool

in Model at line 2256
mixed callNamedScope(string $scope, array $parameters = [])

Apply the given named scope if possible.

Parameters

string $scope
array $parameters

Return Value

mixed

in Model at line 2268
static protected bool isScopeMethodWithAttribute(string $method)

Determine if the given method has a scope attribute.

Parameters

string $method

Return Value

bool

in Model at line 2291
static protected bool isLegacyScopeMethod(string $scope)

Determine if the given method is a callable legacy local scope.

Parameters

string $scope

Return Value

bool

in Model at line 2320
array toArray()

Convert the model instance to an array.

Return Value

array

in Model at line 2333
string toJson(int $options = 0)

Convert the model instance to JSON.

Parameters

int $options

Return Value

string

Exceptions

JsonEncodingException

in Model at line 2349
string toPrettyJson(int $options = 0)

Convert the model instance to pretty print formatted JSON.

Parameters

int $options

Return Value

string

Exceptions

JsonEncodingException

in Model at line 2357
mixed jsonSerialize()

Convert the object into something JSON serializable.

Return Value

mixed

in Model at line 2367
Model|null fresh(array|string $with = [])

Reload a fresh model instance from the database.

Parameters

array|string $with

Return Value

Model|null

in Model at line 2384
Model refresh()

Reload the current model instance with fresh attributes from the database.

Return Value

Model

in Model at line 2398
Model refreshForUpdate()

Reload the current model instance with fresh attributes from the database while locking it for updating.

Return Value

Model

in Model at line 2415
protected Model refreshUsingQuery(Builder $query)

Reload the current model instance using the given query.

Parameters

Builder $query

Return Value

Model

in Model at line 2439
Model replicate(array|null $except = null)

Clone the model into a new, non-existing instance.

Parameters

array|null $except

Return Value

Model

in Model at line 2469
Model replicateQuietly(array|null $except = null)

Clone the model into a new, non-existing instance without raising any events.

Parameters

array|null $except

Return Value

Model

in Model at line 2477
bool is(Model|null $model)

Determine if two models have the same ID and belong to the same table.

Parameters

Model|null $model

Return Value

bool

in Model at line 2494
bool isNot(Model|null $model)

Determine if two models are not the same.

Parameters

Model|null $model

Return Value

bool

in Model at line 2502
Connection getConnection()

Get the database connection for the model.

Return Value

Connection

in Model at line 2510
bool hasApplicableTransaction()

Check for an applicable transaction without borrowing a standard pooled connection.

Return Value

bool

in Model at line 2527
string getConnectionDateFormat()

Get the date format of the query grammar of the model's connection.

Through the database manager this holds no pooled connection once the connection's pool knows the format, so date casts in coroutines that run no query borrow nothing. Models that override how their connection is resolved get the format from that connection.

Return Value

string

in Model at line 2539
protected bool usesDefaultConnectionResolution()

Determine whether this model uses the framework's normal connection resolution.

Return Value

bool

at line 75
string|null getConnectionName()

Get the current connection name for the model.

Return Value

string|null

in Model at line 2560
Model setConnection(UnitEnum|string|null $name)

Set the connection associated with the model.

Parameters

UnitEnum|string|null $name

Return Value

Model

in Model at line 2570
static Connection resolveConnection(UnitEnum|string|null $connection = null)

Resolve a connection instance.

Parameters

UnitEnum|string|null $connection

Return Value

Connection

in Model at line 2578
static ConnectionResolverInterface|null getConnectionResolver()

Get the connection resolver instance.

Return Value

ConnectionResolverInterface|null

in Model at line 2589
static void setConnectionResolver(ConnectionResolverInterface $resolver)

Set the connection resolver instance.

The resolver persists in a static property for the worker lifetime and is used by every model's connection resolution across all coroutines.

Parameters

ConnectionResolverInterface $resolver

Return Value

void

in Model at line 2601
static void unsetConnectionResolver()

Unset the connection resolver for models.

Clears the worker-wide connection resolver shared by every coroutine; concurrent model queries will fail or rebuild.

Return Value

void

in Model at line 2614
static protected mixed resolveClassAttribute(string $attributeClass, string|null $property = null, string|null $class = null)

Resolve an attribute from the model class or its parents.

Parameters

string $attributeClass
string|null $property
string|null $class

Return Value

mixed

in Model at line 2661
protected bool classAttributeOverridesProperty(string $attributeClass, string $property)

Determine whether a class attribute should override the property.

Direct attributes override inherited properties. Inherited attributes only replace more distant property defaults, keeping different values assigned during construction. Assignments equal to a default are indistinguishable from untouched defaults and are replaced.

Parameters

string $attributeClass
string $property

Return Value

bool

in Model at line 2697
static protected string|null classPropertyDeclarer(string $property)

Resolve the nearest class that declares a property.

Parameters

string $property

Return Value

string|null

in Model at line 2716
string getTable()

Get the table associated with the model.

Return Value

string

in Model at line 2726
Model setTable(string $table)

Set the table associated with the model.

Parameters

string $table

Return Value

Model

in Model at line 2736
string|null getKeyName()

Get the primary key for the model.

Return Value

string|null

in Model at line 2746
Model setKeyName(string|null $key)

Set the primary key for the model.

Parameters

string|null $key

Return Value

Model

in Model at line 2758
string getQualifiedKeyName()

Get the table qualified key name.

Return Value

string

in Model at line 2766
string getKeyType()

Get the auto-incrementing key type.

Return Value

string

in Model at line 2776
Model setKeyType(string $type)

Set the data type for the primary key.

Parameters

string $type

Return Value

Model

in Model at line 2788
bool getIncrementing()

Get the value indicating whether the IDs are incrementing.

Return Value

bool

in Model at line 2799
Model setIncrementing(bool $value)

Set whether IDs are incrementing.

Parameters

bool $value

Return Value

Model

in Model at line 2811
mixed getKey()

Get the value of the model's primary key.

Return Value

mixed

in Model at line 2819
mixed getQueueableId()

Get the queueable identity for the entity.

Return Value

mixed

in Model at line 2827
array getQueueableRelations()

Get the queueable relationships for the entity.

Return Value

array

in Model at line 2859
string|null getQueueableConnection()

Get the queueable connection for the entity.

Return Value

string|null

in Model at line 2867
mixed getRouteKey()

Get the value of the model's route key.

Return Value

mixed

in Model at line 2875
string getRouteKeyName()

Get the route key for the model.

Return Value

string

in Model at line 2884
mixed resolveRouteBinding(mixed $value, string|null $field = null)

Retrieve the model for a bound value.

Parameters

mixed $value
string|null $field

Return Value

mixed

in Model at line 2892
mixed resolveSoftDeletableRouteBinding(mixed $value, string|null $field = null)

Retrieve the model for a bound value.

Parameters

mixed $value
string|null $field

Return Value

mixed

in Model at line 2900
mixed resolveChildRouteBinding(string $childType, mixed $value, string|null $field)

Retrieve the child model for a bound value.

Parameters

string $childType
mixed $value
string|null $field

Return Value

mixed

in Model at line 2908
mixed resolveSoftDeletableChildRouteBinding(string $childType, mixed $value, string|null $field)

Retrieve the child model for a bound value.

Parameters

string $childType
mixed $value
string|null $field

Return Value

mixed

in Model at line 2918
protected Relation resolveChildRouteBindingQuery(string $childType, mixed $value, string|null $field)

Retrieve the child model query for a bound value.

Parameters

string $childType
mixed $value
string|null $field

Return Value

Relation

in Model at line 2937
protected string childRouteBindingRelationshipName(string $childType)

Retrieve the child route model binding relationship name for the given child type.

Parameters

string $childType

Return Value

string

in Model at line 2952
Builder|Relation resolveRouteBindingQuery(Model|Builder|Relation $query, mixed $value, string|null $field = null)

Retrieve the model for a bound value.

Parameters

Model|Builder|Relation $query
mixed $value
string|null $field

Return Value

Builder|Relation

Exceptions

ModelNotFoundException<static>

in Model at line 2970
protected bool isValidIntegerRouteKey(mixed $value)

Determine if the given value could address a row in an integer key column.

Parameters

mixed $value

Return Value

bool

in Model at line 2991
protected never handleInvalidRouteKey(mixed $value, string $field)

Throw an exception for the given invalid route key.

Parameters

mixed $value
string $field

Return Value

never

Exceptions

ModelNotFoundException<static>

in Model at line 2999
string getForeignKey()

Get the default foreign key name for the model.

Return Value

string

in Model at line 3007
int getPerPage()

Get the number of models to return per page.

Return Value

int

in Model at line 3017
Model setPerPage(int $perPage)

Set the number of models to return per page.

Parameters

int $perPage

Return Value

Model

in Model at line 3027
static bool isSoftDeletable()

Determine if the model is soft deletable.

Return Value

bool

in Model at line 3035
static bool isPrunable()

Determine if the model is prunable.

Return Value

bool

in Model at line 3043
static bool isMassPrunable()

Determine if the model is mass prunable.

Return Value

bool

in Model at line 3051
static bool preventsLazyLoading()

Determine if lazy loading is disabled.

Return Value

bool

in Model at line 3059
static bool isAutomaticallyEagerLoadingRelationships()

Determine if relationships are being automatically eager loaded when accessed.

Return Value

bool

in Model at line 3068
static bool preventsSilentlyDiscardingAttributes()

Determine if discarding guarded attribute fills is disabled.

Return Value

bool

in Model at line 3076
static bool preventsAccessingMissingAttributes()

Determine if accessing missing attributes is disabled.

Return Value

bool

in Model at line 3084
static bool reportsRouteModelBindingExceptions()

Determine if invalid value exceptions during implicit route model binding should be reported.

Return Value

bool

in Model at line 3092
string broadcastChannelRoute()

Get the broadcast channel route definition that is associated with the given entity.

Return Value

string

in Model at line 3100
string broadcastChannel()

Get the broadcast channel name that is associated with the given entity.

Return Value

string

in Model at line 3108
static void flushGuardableColumns()

Flush cached guardable column metadata.

Return Value

void

in Model at line 3125
static void flushState()

Flush all static state.

Return Value

void

in Model at line 3170
mixed __get(string $key)

Dynamically retrieve attributes on the model.

Parameters

string $key

Return Value

mixed

in Model at line 3178
void __set(string $key, mixed $value)

Dynamically set attributes on the model.

Parameters

string $key
mixed $value

Return Value

void

in Model at line 3188
bool offsetExists(mixed $offset)

Determine if the given attribute exists.

Parameters

mixed $offset

Return Value

bool

in Model at line 3210
mixed offsetGet(mixed $offset)

Get the value for a given offset.

Parameters

mixed $offset

Return Value

mixed

in Model at line 3221
void offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

in Model at line 3231
void offsetUnset(mixed $offset)

Unset the value for a given offset.

Parameters

mixed $offset

Return Value

void

in Model at line 3246
bool __isset(string $key)

Determine if an attribute or relation exists on the model.

Parameters

string $key

Return Value

bool

in Model at line 3254
void __unset(string $key)

Unset an attribute on the model.

Parameters

string $key

Return Value

void

in Model at line 3264
mixed __call(string $method, array $parameters)

Handle dynamic method calls into the model.

Parameters

string $method
array $parameters

Return Value

mixed

in Model at line 3287
static mixed __callStatic(string $method, array $parameters)

Handle dynamic static method calls into the model.

Parameters

string $method
array $parameters

Return Value

mixed

in Model at line 3299
string __toString()

Convert the model to its string representation.

Return Value

string

in Model at line 3311
CanBeEscapedWhenCastToString escapeWhenCastingToString(bool $escape = true)

Indicate that the object's string representation should be escaped when __toString is invoked.

Parameters

bool $escape

Return Value

CanBeEscapedWhenCastToString

in Model at line 3323
array __sleep()

Prepare the object for serialization.

Return Value

array

in Model at line 3348
void __wakeup()

When a model is being unserialized, check if it needs to be booted.

Return Value

void