User
class User extends Model implements Authenticatable, Authorizable, CanResetPassword (View source)
Traits
Constants
CREATED_AT |
The name of the "created at" column. |
UPDATED_AT |
The name of the "updated at" column. |
Properties
protected array | $attributes | The model's attributes. |
from HasAttributes |
protected array | $original | The model attribute's original state. |
from HasAttributes |
protected array | $changes | The changed model attributes. |
from HasAttributes |
protected array | $casts | The attributes that should be cast. |
from HasAttributes |
protected array | $classCastCache | The attributes that have been cast using custom classes. |
from HasAttributes |
protected array | $attributeCastCache | The attributes that have been cast using "Attribute" return type mutators. |
from HasAttributes |
static protected string[] | $primitiveCastTypes | The built-in, primitive cast types supported by Eloquent. |
from HasAttributes |
protected string|null | $dateFormat | The storage format of the model's date columns. |
from HasAttributes |
protected array | $appends | The accessors to append to the model's array form. |
from HasAttributes |
static bool | $snakeAttributes | Indicates whether attributes are snake cased on arrays. |
from HasAttributes |
static protected array | $mutatorCache | The cache of the mutated attributes for each class. |
from HasAttributes |
static protected array | $attributeMutatorCache | The cache of the "Attribute" return type marked mutated attributes for each class. |
from HasAttributes |
static protected array | $getAttributeMutatorCache | The cache of the "Attribute" return type marked mutated, gettable attributes for each class. |
from HasAttributes |
static protected array | $setAttributeMutatorCache | The cache of the "Attribute" return type marked mutated, settable attributes for each class. |
from HasAttributes |
static protected array | $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 | $dispatchesEvents | The event map for the model. |
from HasEvents |
protected array | $observables | User exposed observable events. |
from HasEvents |
protected array | $relations | The loaded relationships for the model. |
from HasRelationships |
protected array | $touches | The relationships that should be touched on save. |
from HasRelationships |
static string[] | $manyMethods | The many to many relationship methods. |
from HasRelationships |
static protected array | $relationResolvers | The relation resolver callbacks. |
from HasRelationships |
bool | $timestamps | Indicates if the model should be timestamped. |
from HasTimestamps |
static protected array | $ignoreTimestampsOn | The list of models classes that have timestamps temporarily disabled. |
from HasTimestamps |
bool | $usesUniqueIds | Indicates if the model uses unique ids. |
from HasUniqueIds |
protected string[] | The attributes that should be hidden for serialization. |
from HidesAttributes | |
protected 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[]|bool | $guarded | The attributes that aren't mass assignable. |
from GuardsAttributes |
static protected bool | $unguarded | Indicates if all mass assignment is enabled. |
from GuardsAttributes |
static protected string[] | $guardableColumns | The actual columns that exist on the database and can be guarded. |
from GuardsAttributes |
static protected WeakMap<static,array<string,mixed>> | $recursionCache | The cache of objects processed to prevent infinite recursion. |
from PreventsCircularRecursion |
static protected | $resolvedCollectionClasses | from HasCollection | |
protected string|null | $connection | The connection name for the model. |
from Model |
protected string|null | $table | The table associated with the model. |
from Model |
protected string | $primaryKey | The primary key for the model. |
from Model |
protected string | $keyType | The "type" of the primary key ID. |
from Model |
bool | $incrementing | Indicates if the IDs are auto-incrementing. |
from Model |
protected array | $with | The relations to eager load on every query. |
from Model |
protected array | $withCount | The relationship counts that should be eager loaded on every query. |
from Model |
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 |
static protected ConnectionResolverInterface | $resolver | The connection resolver instance. |
from Model |
static protected Dispatcher|null | $dispatcher | The event dispatcher instance. |
from Model |
static protected array | $booted | The array of booted models. |
from Model |
static protected array | $traitInitializers | The array of trait initializers that will be called on each new instance. |
from Model |
static protected array | $globalScopes | The array of global scopes on the model. |
from Model |
static protected array | $ignoreOnTouch | The list of models classes that should not be affected with touch. |
from Model |
static protected bool | $modelsShouldPreventLazyLoading | Indicates whether lazy loading should be restricted on all models. |
from Model |
static protected callable|null | $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 callable|null | $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 callable|null | $missingAttributeViolationCallback | The callback that is responsible for handling missing attribute violations. |
from Model |
static protected bool | $isBroadcasting | Indicates if broadcasting is currently enabled. |
from Model |
static protected | $builder | The Eloquent query builder class to use for the model. |
from Model |
static protected | $collectionClass | The Eloquent collection class to use for the model. |
from Model |
protected string | $authPasswordName | The column name of the password field using during authentication. |
from Authenticatable |
protected string | $rememberTokenName | The column name of the "remember me" token. |
from Authenticatable |
Methods
Add the date attributes to the attributes array.
Add the mutated attributes to the attributes array.
Add the casted attributes to the attributes array.
Get an attribute array of all arrayable attributes.
Get an attribute array of all arrayable values.
Determine whether an attribute exists on the model.
Either throw a missing attribute exception or return null depending on Eloquent's configuration.
Get an attribute from the $attributes array.
Determine if the given key is a relationship method on the model.
Get a relationship value from a method.
Determine if a get mutator exists for an attribute.
Determine if a "Attribute" return type marked mutator exists for an attribute.
Determine if a "Attribute" return type marked get mutator exists for an attribute.
Determine if any get mutator exists for an attribute.
Get the value of an attribute using its mutator.
Get the value of an "Attribute" return type marked attribute using its mutator.
Get the value of an attribute using its mutator for array conversion.
Ensure that the given casts are strings.
Cast an attribute to a native PHP type.
Cast the given attribute using a custom cast class.
Cast the given attribute to an enum.
Increment or decrement the given attribute using the custom cast class.
Serialize the given attribute using the custom cast class.
Determine if the cast type is a custom date time cast.
Determine if the cast type is an immutable custom date time cast.
Set a given attribute on the model.
Determine if a set mutator exists for an attribute.
Determine if an "Attribute" return type marked set mutator exists for an attribute.
Set the value of an attribute using its mutator.
Set the value of a "Attribute" return type marked attribute using its mutator.
Determine if the given attribute is a date or date castable.
Set a given JSON attribute on the model.
Set the value of a class castable attribute.
Set the value of an enum castable attribute.
Get an enum case instance from a given class and value.
Get the storable value from the given enum.
Get an array attribute with the given key and value set.
Get an array attribute or return an empty array if it is not set.
Cast the given attribute to JSON.
Get the JSON casting flags for the given attribute.
Decode the given JSON back into an array or object.
Cast the given attribute to an encrypted string.
Set the encrypter instance that will be used to encrypt attributes.
Get the current encrypter being used by the model.
Cast the given attribute to a hashed string.
Return a timestamp as DateTime object with time set to 00:00:00.
Determine if the given value is a standard date format.
Determine whether an attribute should be cast to a native type.
Determine whether a value is Date / DateTime castable for inbound manipulation.
Determine whether a value is Date / DateTime custom-castable for inbound manipulation.
Determine whether a value is JSON castable for inbound manipulation.
Determine whether a value is an encrypted castable for inbound manipulation.
Determine if the given key is cast using a custom class.
Determine if the given key is cast using an enum.
Determine if the key is deviable using a custom class.
Determine if the key is serializable using a custom class.
Resolve the custom caster class for a given key.
Parse the given caster class, removing any arguments.
Merge the cast class and attribute cast attributes back into the model.
Merge the cast class attributes back into the model.
Merge the cast class attributes back into the model.
Normalize the response from a custom class caster.
Get all of the current attributes on the model.
Get all of the current attributes on the model for an insert operation.
Set the array of model attributes. No checking is done.
Get the model's original attribute values.
Get the model's original attribute values.
Get the model's raw original attribute values.
Sync a single original attribute with its current value.
Sync multiple original attribute with their current values.
Determine if the model or any of the given attribute(s) have been modified.
Determine if the model or all the given attribute(s) have remained the same.
Discard attribute changes and reset the attributes to their original state.
Determine if the model or any of the given attribute(s) were changed when the model was last saved.
Determine if any of the given attributes were changed when the model was last saved.
Get the attributes that have been changed since the last sync for an update operation.
Get the attributes that were changed when the model was last saved.
Determine if the new and old values for a given key are equivalent.
Transform a raw model value using mutators, casts, etc.
Append attributes to query when building a query.
Return whether the accessor attribute has been appended.
Extract and cache all the mutated attributes of a class.
Get all of the attribute mutator methods.
Get all of the "Attribute" return typed attribute mutator methods.
Resolve the observe class names from the attributes.
Register a single observer with the model.
Remove an observable event name.
Register a model event with the dispatcher.
Fire the given event for the model.
Fire a custom model event for the given event.
Register a retrieved model event with the dispatcher.
Register a saving model event with the dispatcher.
Register a saved model event with the dispatcher.
Register an updating model event with the dispatcher.
Register an updated model event with the dispatcher.
Register a creating model event with the dispatcher.
Register a created model event with the dispatcher.
Register a replicating model event with the dispatcher.
Register a deleting model event with the dispatcher.
Register a deleted model event with the dispatcher.
Execute a callback without firing any model events for any model type.
Boot the has global scopes trait for a model.
Resolve the global scope class names from the attributes.
Register a new global scope on the model.
Register multiple global scopes on the model.
Get all of the global scopes that are currently registered.
Get the dynamic relation resolver if defined or inherited, or return null.
Define a one-to-one relationship.
Instantiate a new HasOne relationship.
No description
No description
Define a polymorphic one-to-one relationship.
Instantiate a new MorphOne relationship.
Define an inverse one-to-one or many relationship.
Instantiate a new BelongsTo relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Instantiate a new MorphTo relationship.
Retrieve the actual class name for a given morph class.
Create a pending has-many-through or has-one-through relationship.
Define a one-to-many relationship.
Instantiate a new HasMany relationship.
No description
No description
Define a polymorphic one-to-many relationship.
Instantiate a new MorphMany relationship.
No description
No description
Define a polymorphic many-to-many relationship.
Instantiate a new MorphToMany relationship.
Define a polymorphic, inverse many-to-many relationship.
Get the relationship name of the belongsToMany relationship.
Get the joining table name for a many-to-many relation.
Get this model's half of the intermediate table name for belongsToMany relationships.
Determine if the model touches a given relation.
Get the polymorphic relationship columns.
Create a new model instance for a related model.
Create a new model instance for a related "through" model.
Set the given relationship on the model.
Set the entire relations array on the model.
Duplicate the instance and unset all the loaded relations.
Set the relationships that are touched on save.
Update the model's update timestamp without raising any events.
Get the fully qualified "created at" column.
Get the fully qualified "updated at" column.
Disable timestamps for the current class during the given callback scope.
Disable timestamps for the given model classes during the given callback scope.
Determine if the given model is ignoring timestamps / touches.
Make the given, typically hidden, attributes visible.
Make the given, typically hidden, attributes visible if the given truth test passes.
Make the given, typically visible, attributes hidden.
Make the given, typically visible, attributes hidden if the given truth test passes.
Merge new fillable attributes with existing fillable attributes on the model.
Merge new guarded attributes with existing guarded attributes on the model.
Disable all mass assignable restrictions.
Run the given callable while being unguarded.
Determine if the given attribute may be mass assigned.
Determine if the given column is a valid, guardable column.
Get the fillable attributes of a given array.
Prevent a method from being called multiple times on the same object within the same call stack.
Remove an entry from the recursion cache for an object.
Get the stack of methods being called recursively for the current object.
Get the current recursion cache being used by the model.
Set a value in the recursion cache for the given object and method.
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Create a new Eloquent Collection instance.
Resolve the collection class name from the CollectedBy attribute.
Clear the list of booted models so they will be re-booted.
Disables relationship model touching for the current class during given callback scope.
Disables relationship model touching for the given model classes during given callback scope.
Determine if the given model is ignoring touches.
Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.
Prevent model relationships from being lazy loaded.
Register a callback that is responsible for handling lazy loading violations.
Prevent non-fillable attributes from being silently discarded.
Register a callback that is responsible for handling discarded attribute violations.
Prevent accessing missing attributes on retrieved models.
Register a callback that is responsible for handling missing attribute violations.
Execute a callback without broadcasting any model events for all model types.
Fill the model with an array of attributes. Force mass assignment.
Create a new instance of the given model.
Create a new model instance that is existing.
Begin querying the model on a given connection.
Begin querying the model on the write connection.
Get all of the models from the database.
Begin querying a model with eager loading.
Eager load relationships on the polymorphic relation of a model.
Eager load relations on the model if they are not already eager loaded.
Eager load relation's column aggregations on the model.
Eager load relation max column values on the model.
Eager load relation min column values on the model.
Eager load relation's column summations on the model.
Eager load relation average column values on the model.
Eager load related model existence values on the model.
Eager load relationship column aggregation on the polymorphic relation of a model.
Eager load relationship counts on the polymorphic relation of a model.
Eager load relationship max column values on the polymorphic relation of a model.
Eager load relationship min column values on the polymorphic relation of a model.
Eager load relationship column summations on the polymorphic relation of a model.
Eager load relationship average column values on the polymorphic relation of a model.
Increment a column's value by a given amount.
Decrement a column's value by a given amount.
Run the increment or decrement method on the model.
Update the model in the database.
Update the model in the database within a transaction.
Update the model in the database without raising any events.
Increment a column's value by a given amount without raising any events.
Decrement a column's value by a given amount without raising any events.
Save the model and all of its relationships without raising any events to the parent model.
Save the model to the database without raising any events.
Save the model to the database within a transaction.
Perform any actions that are necessary after the model is saved.
Set the keys for a select query.
Set the keys for a save update query.
Insert the given attributes and set the ID on the model.
Get a new query builder that doesn't have any global scopes or eager loading.
Get a new query builder with no relationships loaded.
Register the global scopes for this builder instance.
Get a new query builder that doesn't have any global scopes.
Get a new query to restore one or more models by their queueable IDs.
Create a new pivot model instance.
Apply the given named scope if possible.
Determine if the given method has a scope attribute.
Reload a fresh model instance from the database.
Reload the current model instance with fresh attributes from the database.
Clone the model into a new, non-existing instance without raising any events.
Resolve a connection instance.
Get the connection resolver instance.
Retrieve the model for a bound value.
Retrieve the model for a bound value.
Retrieve the child model for a bound value.
Retrieve the child model for a bound value.
Retrieve the child route model binding relationship name for the given child type.
Retrieve the model for a bound value.
Determine if discarding guarded attribute fills is disabled.
Determine if accessing missing attributes is disabled.
Get the broadcast channel route definition that is associated with the given entity.
Get the broadcast channel name that is associated with the given entity.
Handle dynamic method calls into the model.
Handle dynamic static method calls into the model.
Indicate that the object's string representation should be escaped when __toString is invoked.
Get the name of the unique identifier for the user.
Get the unique broadcast identifier for the user.
Get the name of the password attribute for the user.
Get the token value for the "remember me" session.
Set the token value for the "remember me" session.
Determine if the entity has the given abilities.
Determine if the entity has any of the given abilities.
Determine if the entity does not have the given abilities.
Determine if the entity does not have the given abilities.
Get the e-mail address where password reset links are sent.
Send the password reset notification.
Determine if the user has verified their email address.
Send the email verification notification.
Get the email address that should be used for verification.
Details
protected array
addDateAttributesToArray(array $attributes)
Add the date attributes to the attributes array.
protected array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)
Add the mutated attributes to the attributes array.
protected array
addCastAttributesToArray(array $attributes, array $mutatedAttributes)
Add the casted attributes to the attributes array.
protected null
throwMissingAttributeExceptionIfApplicable(string $key)
Either throw a missing attribute exception or return null depending on Eloquent's configuration.
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.
protected mixed
mutateAttribute(string $key, mixed $value)
Get the value of an attribute using its mutator.
protected mixed
mutateAttributeMarkedAttribute(string $key, mixed $value)
Get the value of an "Attribute" return type marked attribute using its mutator.
protected mixed
mutateAttributeForArray(string $key, mixed $value)
Get the value of an attribute using its mutator for array conversion.
protected mixed
getClassCastableAttributeValue(string $key, mixed $value)
Cast the given attribute using a custom cast class.
protected mixed
getEnumCastableAttributeValue(string $key, mixed $value)
Cast the given attribute to an enum.
protected mixed
deviateClassCastableAttribute(string $method, string $key, mixed $value)
Increment or decrement the given attribute using the custom cast class.
protected mixed
serializeClassCastableAttribute(string $key, mixed $value)
Serialize the given attribute using the custom cast class.
protected bool
isCustomDateTimeCast(string $cast)
Determine if the cast type is a custom date time cast.
protected bool
isImmutableCustomDateTimeCast(string $cast)
Determine if the cast type is an immutable custom date time cast.
bool
hasAttributeSetMutator(string $key)
Determine if an "Attribute" return type marked set mutator exists for an attribute.
protected mixed
setMutatedAttributeValue(string $key, mixed $value)
Set the value of an attribute using its mutator.
protected mixed
setAttributeMarkedMutatedAttributeValue(string $key, mixed $value)
Set the value of a "Attribute" return type marked attribute using its mutator.
protected bool
isDateAttribute(string $key)
Determine if the given attribute is a date or date castable.
protected void
setClassCastableAttribute(string $key, mixed $value)
Set the value of a class castable attribute.
protected void
setEnumCastableAttribute(string $key, UnitEnum|string|int|null $value)
Set the value of an enum castable attribute.
protected UnitEnum|BackedEnum
getEnumCaseFromValue(string $enumClass, string|int $value)
Get an enum case instance from a given class and value.
protected string|int
getStorableEnumValue(string $expectedEnum, UnitEnum|BackedEnum $value)
Get the storable value from the given enum.
protected $this
getArrayAttributeWithValue(string $path, string $key, mixed $value)
Get an array attribute with the given key and value set.
protected array
getArrayAttributeByKey(string $key)
Get an array attribute or return an empty array if it is not set.
mixed
fromJson(string|null $value, bool $asObject = false)
Decode the given JSON back into an array or object.
protected 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.
protected string
castAttributeAsHashedString(string $key, mixed $value)
Cast the given attribute to a hashed string.
protected Carbon
asDate(mixed $value)
Return a timestamp as DateTime object with time set to 00:00:00.
protected bool
isStandardDateFormat(string $value)
Determine if the given value is a standard date format.
protected string
serializeDate(DateTimeInterface $date)
Prepare a date for array / JSON serialization.
bool
hasCast(string $key, array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
protected bool
isDateCastable(string $key)
Determine whether a value is Date / DateTime castable for inbound manipulation.
protected bool
isDateCastableWithCustomFormat(string $key)
Determine whether a value is Date / DateTime custom-castable for inbound manipulation.
protected bool
isJsonCastable(string $key)
Determine whether a value is JSON castable for inbound manipulation.
protected bool
isEncryptedCastable(string $key)
Determine whether a value is an encrypted castable for inbound manipulation.
protected bool
isClassCastable(string $key)
Determine if the given key is cast using a custom class.
protected bool
isClassSerializable(string $key)
Determine if the key is serializable using a custom class.
protected string
parseCasterClass(string $class)
Parse the given caster class, removing any arguments.
protected void
mergeAttributesFromCachedCasts()
Merge the cast class and attribute cast attributes back into the model.
protected void
mergeAttributesFromAttributeCasts()
Merge the cast class attributes back into the model.
protected array
normalizeCastClassResponse(string $key, mixed $value)
Normalize the response from a custom class caster.
protected array
getAttributesForInsert()
Get all of the current attributes on the model for an insert operation.
$this
setRawAttributes(array $attributes, bool $sync = false)
Set the array of model attributes. No checking is done.
mixed|array
getOriginal(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
protected mixed|array
getOriginalWithoutRewindingModel(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
mixed|array
getRawOriginal(string|null $key = null, mixed $default = null)
Get the model's raw original attribute values.
$this
syncOriginalAttribute(string $attribute)
Sync a single original attribute with its current value.
$this
syncOriginalAttributes(array|string $attributes)
Sync multiple original attribute with their current values.
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.
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.
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.
protected array
getDirtyForUpdate()
Get the attributes that have been changed since the last sync for an update operation.
bool
originalIsEquivalent(string $key)
Determine if the new and old values for a given key are equivalent.
protected mixed
transformModelValue(string $key, mixed $value)
Transform a raw model value using mutators, casts, etc.
static void
cacheMutatedAttributes(object|string $classOrInstance)
Extract and cache all the mutated attributes of a class.
static protected array
getAttributeMarkedMutatorMethods(mixed $class)
Get all of the "Attribute" return typed attribute mutator methods.
static protected void
registerModelEvent(string $event, QueuedClosure|callable|array|class-string $callback)
Register a model event with the dispatcher.
protected mixed
fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
protected mixed|null
fireCustomModelEvent(string $event, string $method)
Fire a custom model event for the given event.
static void
retrieved(QueuedClosure|callable|array|class-string $callback)
Register a retrieved model event with the dispatcher.
static void
saving(QueuedClosure|callable|array|class-string $callback)
Register a saving model event with the dispatcher.
static void
saved(QueuedClosure|callable|array|class-string $callback)
Register a saved model event with the dispatcher.
static void
updating(QueuedClosure|callable|array|class-string $callback)
Register an updating model event with the dispatcher.
static void
updated(QueuedClosure|callable|array|class-string $callback)
Register an updated model event with the dispatcher.
static void
creating(QueuedClosure|callable|array|class-string $callback)
Register a creating model event with the dispatcher.
static void
created(QueuedClosure|callable|array|class-string $callback)
Register a created model event with the dispatcher.
static void
replicating(QueuedClosure|callable|array|class-string $callback)
Register a replicating model event with the dispatcher.
static void
deleting(QueuedClosure|callable|array|class-string $callback)
Register a deleting model event with the dispatcher.
static void
deleted(QueuedClosure|callable|array|class-string $callback)
Register a deleted model event with the dispatcher.
static mixed
withoutEvents(callable $callback)
Execute a callback without firing any model events for any model type.
static array
resolveGlobalScopeAttributes()
Resolve the global scope class names from the attributes.
static mixed
addGlobalScope($scope, $implementation = null)
Register a new global scope on the model.
Closure|null
relationResolver(TRelatedModel> $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.
TRelatedModel,$this>
hasOne(TRelatedModel> $related, string|null $foreignKey = null, string|null $localKey = null)
Define a one-to-one relationship.
protected TDeclaringModel>
newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasOne relationship.
hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
No description
protected
newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
No description
TRelatedModel,$this>
morphOne(TRelatedModel> $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)
Define a polymorphic one-to-one relationship.
protected TDeclaringModel>
newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphOne relationship.
TRelatedModel,$this>
belongsTo(TRelatedModel> $related, string|null $foreignKey = null, string|null $ownerKey = null, string|null $relation = null)
Define an inverse one-to-one or many relationship.
protected TDeclaringModel>
newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)
Instantiate a new BelongsTo relationship.
Model,$this>
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.
protected Model,$this>
morphEagerTo(string $name, string $type, string $id, string|null $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
protected Model,$this>
morphInstanceTo(string $target, string $name, string $type, string $id, string|null $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
protected TDeclaringModel>
newMorphTo(Builder $query, Model $parent, string $foreignKey, string|null $ownerKey, string $type, string $relation)
Instantiate a new MorphTo relationship.
static string
getActualClassNameForMorph(string $class)
Retrieve the actual class name for a given morph class.
TRelatedModel,$this>
hasMany(TRelatedModel> $related, string|null $foreignKey = null, string|null $localKey = null)
Define a one-to-many relationship.
protected TDeclaringModel>
newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasMany relationship.
hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
No description
protected
newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
No description
TRelatedModel,$this>
morphMany(TRelatedModel> $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)
Define a polymorphic one-to-many relationship.
protected TDeclaringModel>
newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphMany relationship.
belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, $parentKey = null, $relatedKey = null, $relation = null)
No description
protected
newBelongsToMany(Builder $query, Model $parent, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, $relationName = null)
No description
TRelatedModel,$this>
morphToMany(TRelatedModel> $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.
protected TDeclaringModel>
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.
TRelatedModel,$this>
morphedByMany(TRelatedModel> $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.
protected 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.
protected array
getMorphs(string $name, string $type, string $id)
Get the polymorphic relationship columns.
protected TRelatedModel
newRelatedInstance(TRelatedModel> $class)
Create a new model instance for a related model.
protected TRelatedModel
newRelatedThroughInstance(TRelatedModel> $class)
Create a new model instance for a related "through" model.
bool
touchQuietly(string|null $attribute = null)
Update the model's update timestamp without raising any events.
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.
$this
makeVisible(string[]|string|null $attributes)
Make the given, typically hidden, attributes visible.
$this
makeVisibleIf(bool|Closure $condition, string[]|string|null $attributes)
Make the given, typically hidden, attributes visible if the given truth test passes.
$this
makeHidden(string[]|string|null $attributes)
Make the given, typically visible, attributes hidden.
$this
makeHiddenIf(bool|Closure $condition, string[]|string|null $attributes)
Make the given, typically visible, attributes hidden if the given truth test passes.
$this
mergeFillable(array $fillable)
Merge new fillable attributes with existing fillable attributes on the model.
$this
mergeGuarded(array $guarded)
Merge new guarded attributes with existing guarded attributes on the model.
protected bool
isGuardableColumn(string $key)
Determine if the given column is a valid, guardable column.
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.
static protected
clearRecursiveCallValue(object $object, string $hash)
Remove an entry from the recursion cache for an object.
static protected array
getRecursiveCallStack(object $object)
Get the stack of methods being called recursively for the current object.
static protected WeakMap
getRecursionCache()
Get the current recursion cache being used by the model.
static protected mixed
setRecursiveCallValue(object $object, string $hash, mixed $value)
Set a value in the recursion cache for the given object and method.
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
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.
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
TCollection>|null
resolveCollectionFromAttribute()
Resolve the collection class name from the CollectedBy attribute.
in
Model at line 270
protected void
bootIfNotBooted()
Check if the model needs to be booted and if so, do it.
in
Model at line 290
static protected void
booting()
Perform any actions required before the model boots.
in
Model at line 310
static protected void
bootTraits()
Boot all of the bootable traits on the model.
in
Model at line 342
protected void
initializeTraits()
Initialize any initializable traits on the model.
in
Model at line 354
static protected void
booted()
Perform any actions required after the model boots.
in
Model at line 364
static void
clearBootedModels()
Clear the list of booted models so they will be re-booted.
in
Model at line 377
static void
withoutTouching(callable $callback)
Disables relationship model touching for the current class during given callback scope.
in
Model at line 389
static void
withoutTouchingOn(array $models, callable $callback)
Disables relationship model touching for the given model classes during given callback scope.
in
Model at line 406
static bool
isIgnoringTouch(string|null $class = null)
Determine if the given model is ignoring touches.
in
Model at line 429
static void
shouldBeStrict(bool $shouldBeStrict = true)
Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.
in
Model at line 442
static void
preventLazyLoading(bool $value = true)
Prevent model relationships from being lazy loaded.
in
Model at line 453
static void
handleLazyLoadingViolationUsing(callable|null $callback)
Register a callback that is responsible for handling lazy loading violations.
in
Model at line 464
static void
preventSilentlyDiscardingAttributes(bool $value = true)
Prevent non-fillable attributes from being silently discarded.
in
Model at line 475
static void
handleDiscardedAttributeViolationUsing(callable|null $callback)
Register a callback that is responsible for handling discarded attribute violations.
in
Model at line 486
static void
preventAccessingMissingAttributes(bool $value = true)
Prevent accessing missing attributes on retrieved models.
in
Model at line 497
static void
handleMissingAttributeViolationUsing(callable|null $callback)
Register a callback that is responsible for handling missing attribute violations.
in
Model at line 508
static mixed
withoutBroadcasting(callable $callback)
Execute a callback without broadcasting any model events for all model types.
in
Model at line 577
$this
forceFill(array $attributes)
Fill the model with an array of attributes. Force mass assignment.
in
Model at line 588
string
qualifyColumn(string $column)
Qualify the given column name by the model's table.
in
Model at line 603
array
qualifyColumns(array $columns)
Qualify the given columns with the model's table.
in
Model at line 617
Model
newInstance(array $attributes = [], bool $exists = false)
Create a new instance of the given model.
in
Model at line 646
Model
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance that is existing.
in
Model at line 665
static Builder<static>
on(string|null $connection = null)
Begin querying the model on a given connection.
in
Model at line 682
static Builder<static>
onWriteConnection()
Begin querying the model on the write connection.
in
Model at line 693
static Collection<int,static>
all(array|string $columns = ['*'])
Get all of the models from the database.
in
Model at line 706
static Builder<static>
with(array|string $relations)
Begin querying a model with eager loading.
in
Model at line 737
$this
loadMorph(string $relation, array $relations)
Eager load relationships on the polymorphic relation of a model.
in
Model at line 756
$this
loadMissing(array|string $relations)
Eager load relations on the model if they are not already eager loaded.
in
Model at line 773
$this
loadAggregate(array|string $relations, string $column, string|null $function = null)
Eager load relation's column aggregations on the model.
in
Model at line 786
$this
loadCount(array|string $relations)
Eager load relation counts on the model.
in
Model at line 800
$this
loadMax(array|string $relations, string $column)
Eager load relation max column values on the model.
in
Model at line 812
$this
loadMin(array|string $relations, string $column)
Eager load relation min column values on the model.
in
Model at line 824
$this
loadSum(array|string $relations, string $column)
Eager load relation's column summations on the model.
in
Model at line 836
$this
loadAvg(array|string $relations, string $column)
Eager load relation average column values on the model.
in
Model at line 847
$this
loadExists(array|string $relations)
Eager load related model existence values on the model.
in
Model at line 861
$this
loadMorphAggregate(string $relation, array $relations, string $column, string|null $function = null)
Eager load relationship column aggregation on the polymorphic relation of a model.
in
Model at line 881
$this
loadMorphCount(string $relation, array $relations)
Eager load relationship counts on the polymorphic relation of a model.
in
Model at line 894
$this
loadMorphMax(string $relation, array $relations, string $column)
Eager load relationship max column values on the polymorphic relation of a model.
in
Model at line 907
$this
loadMorphMin(string $relation, array $relations, string $column)
Eager load relationship min column values on the polymorphic relation of a model.
in
Model at line 920
$this
loadMorphSum(string $relation, array $relations, string $column)
Eager load relationship column summations on the polymorphic relation of a model.
in
Model at line 933
$this
loadMorphAvg(string $relation, array $relations, string $column)
Eager load relationship average column values on the polymorphic relation of a model.
in
Model at line 946
protected int
increment(string $column, float|int $amount = 1, array $extra = [])
Increment a column's value by a given amount.
in
Model at line 959
protected int
decrement(string $column, float|int $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
in
Model at line 973
protected int
incrementOrDecrement(string $column, float|int $amount, array $extra, string $method)
Run the increment or decrement method on the model.
bool
updateOrFail(array $attributes = [], array $options = [])
Update the model in the database within a transaction.
bool
updateQuietly(array $attributes = [], array $options = [])
Update the model in the database without raising any events.
protected int
incrementQuietly(string $column, float|int $amount = 1, array $extra = [])
Increment a column's value by a given amount without raising any events.
protected int
decrementQuietly(string $column, float|int $amount = 1, array $extra = [])
Decrement a column's value by a given amount without raising any events.
bool
pushQuietly()
Save the model and all of its relationships without raising any events to the parent model.
protected void
finishSave(array $options)
Perform any actions that are necessary after the model is saved.
protected Builder<static>
setKeysForSelectQuery(Builder<static> $query)
Set the keys for a select query.
protected Builder<static>
setKeysForSaveQuery(Builder<static> $query)
Set the keys for a save update query.
protected void
insertAndSetId(Builder $query, array $attributes)
Insert the given attributes and set the ID on the model.
bool|null
forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when the trait is missing.
static bool|null
forceDestroy(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.
Builder<static>
newModelQuery()
Get a new query builder that doesn't have any global scopes or eager loading.
Builder<static>
newQueryWithoutRelationships()
Get a new query builder with no relationships loaded.
Builder<static>
registerGlobalScopes(Builder<static> $builder)
Register the global scopes for this builder instance.
Builder<static>
newQueryWithoutScopes()
Get a new query builder that doesn't have any global scopes.
Builder<static>
newQueryWithoutScope(Scope|string $scope)
Get a new query instance without a given scope.
Builder<static>
newQueryForRestoration(array|int $ids)
Get a new query to restore one or more models by their queueable IDs.
Pivot
newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)
Create a new pivot model instance.
mixed
callNamedScope(string $scope, array $parameters = [])
Apply the given named scope if possible.
static protected bool
isScopeMethodWithAttribute(string $method)
Determine if the given method has a scope attribute.
Model
replicateQuietly(array|null $except = null)
Clone the model into a new, non-existing instance without raising any events.
static ConnectionResolverInterface|null
getConnectionResolver()
Get the connection resolver instance.
static void
setConnectionResolver(ConnectionResolverInterface $resolver)
Set the connection resolver instance.
Model|null
resolveRouteBinding(mixed $value, string|null $field = null)
Retrieve the model for a bound value.
Model|null
resolveSoftDeletableRouteBinding(mixed $value, string|null $field = null)
Retrieve the model for a bound value.
Model|null
resolveChildRouteBinding(string $childType, mixed $value, string|null $field)
Retrieve the child model for a bound value.
Model|null
resolveSoftDeletableChildRouteBinding(string $childType, mixed $value, string|null $field)
Retrieve the child model for a bound value.
protected string
childRouteBindingRelationshipName(string $childType)
Retrieve the child route model binding relationship name for the given child type.
Builder
resolveRouteBindingQuery(Model|Builder|Relation $query, mixed $value, string|null $field = null)
Retrieve the model for a bound value.
static bool
preventsSilentlyDiscardingAttributes()
Determine if discarding guarded attribute fills is disabled.
static bool
preventsAccessingMissingAttributes()
Determine if accessing missing attributes is disabled.
string
broadcastChannelRoute()
Get the broadcast channel route definition that is associated with the given entity.
static mixed
__callStatic(string $method, array $parameters)
Handle dynamic static method calls into the model.
$this
escapeWhenCastingToString(bool $escape = true)
Indicate that the object's string representation should be escaped when __toString is invoked.
bool
can(iterable|BackedEnum|string $abilities, array|mixed $arguments = [])
Determine if the entity has the given abilities.
bool
canAny(iterable|BackedEnum|string $abilities, array|mixed $arguments = [])
Determine if the entity has any of the given abilities.
bool
cant(iterable|BackedEnum|string $abilities, array|mixed $arguments = [])
Determine if the entity does not have the given abilities.
bool
cannot(iterable|BackedEnum|string $abilities, array|mixed $arguments = [])
Determine if the entity does not have the given abilities.