Model
abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToString, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable (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 | $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 |
$hidden | 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 |
protected string|null | $connection | The connection name for the model. |
|
protected string | $table | The table associated with the model. |
|
protected string | $primaryKey | The primary key for the model. |
|
protected string | $keyType | The "type" of the primary key ID. |
|
bool | $incrementing | Indicates if the IDs are auto-incrementing. |
|
protected array | $with | The relations to eager load on every query. |
|
protected array | $withCount | The relationship counts that should be eager loaded on every query. |
|
bool | $preventsLazyLoading | Indicates whether lazy loading will be prevented on this model. |
|
protected int | $perPage | The number of models to return for pagination. |
|
bool | $exists | Indicates if the model exists. |
|
bool | $wasRecentlyCreated | Indicates if the model was inserted during the object's lifecycle. |
|
protected bool | $escapeWhenCastingToString | Indicates that the object's string representation should be escaped when __toString is invoked. |
|
static protected ConnectionResolverInterface | $resolver | The connection resolver instance. |
|
static protected Dispatcher | $dispatcher | The event dispatcher instance. |
|
static protected array | $booted | The array of booted models. |
|
static protected array | $traitInitializers | The array of trait initializers that will be called on each new instance. |
|
static protected array | $globalScopes | The array of global scopes on the model. |
|
static protected array | $ignoreOnTouch | The list of models classes that should not be affected with touch. |
|
static protected bool | $modelsShouldPreventLazyLoading | Indicates whether lazy loading should be restricted on all models. |
|
static protected callable|null | $lazyLoadingViolationCallback | The callback that is responsible for handling lazy loading violations. |
|
static protected bool | $modelsShouldPreventSilentlyDiscardingAttributes | Indicates if an exception should be thrown instead of silently discarding non-fillable attributes. |
|
static protected callable|null | $discardedAttributeViolationCallback | The callback that is responsible for handling discarded attribute violations. |
|
static protected bool | $modelsShouldPreventAccessingMissingAttributes | Indicates if an exception should be thrown when trying to access a missing attribute on a retrieved model. |
|
static protected callable|null | $missingAttributeViolationCallback | The callback that is responsible for handling missing attribute violations. |
|
static protected bool | $isBroadcasting | Indicates if broadcasting is currently enabled. |
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.
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.
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.
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.
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.
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 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.
Define a has-one-through relationship.
Instantiate a new HasOneThrough relationship.
Define a polymorphic one-to-one relationship.
Instantiate a new MorphOne relationship.
Define an inverse one-to-one or many relationship.
Instantiate a new BelongsTo relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Instantiate a new MorphTo relationship.
Retrieve the actual class name for a given morph class.
Create a pending has-many-through or has-one-through relationship.
Define a one-to-many relationship.
Instantiate a new HasMany relationship.
Define a has-many-through relationship.
Instantiate a new HasManyThrough relationship.
Define a polymorphic one-to-many relationship.
Instantiate a new MorphMany relationship.
Define a many-to-many relationship.
Instantiate a new BelongsToMany relationship.
Define a polymorphic many-to-many relationship.
Instantiate a new MorphToMany relationship.
Define a polymorphic, inverse many-to-many relationship.
Get the relationship name of the belongsToMany relationship.
Get the joining table name for a many-to-many relation.
Get this model's half of the intermediate table name for belongsToMany relationships.
Determine if the model touches a given relation.
Get the polymorphic relationship columns.
Create a new model instance for a related model.
Create a new model instance for a related "through" model.
Set the given relationship on the model.
Set the entire relations array on the model.
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.
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 model instance.
Check if the model needs to be booted and if so, do it.
Perform any actions required before the model boots.
Bootstrap the model and its traits.
Boot all of the bootable traits on the model.
Initialize any initializable traits on the model.
Perform any actions required after the model boots.
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.
Fill the model with an array of attributes. Force mass assignment.
Qualify the given column name by the model's table.
Qualify the given columns with the model's table.
Create a new instance of the given model.
Create a new model instance that is existing.
Begin querying the model on the write connection.
Get all of the models from the database.
Eager load relations on the model.
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 counts 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.
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.
Save the model to the database within a transaction.
Perform any actions that are necessary after the model is saved.
Get the primary key value for a select query.
Get the primary key value for a save query.
Insert the given attributes and set the ID on the model.
Delete the model from the database.
Delete the model from the database without raising any events.
Delete the model from the database within a transaction.
Force a hard delete on a soft deleted model.
Perform the actual delete query on this model instance.
Get a new query builder that doesn't have any global scopes or eager loading.
Get a new query builder with no relationships loaded.
Get a new query builder that doesn't have any global scopes.
Get a new query to restore one or more models by their queueable IDs.
Get a new query builder instance for the connection.
Create a new Eloquent Collection instance.
Determine if the model has a given scope.
Apply the given named scope if possible.
Convert the model instance to an array.
Convert the model instance to JSON.
Convert the object into something JSON serializable.
Reload the current model instance with fresh attributes from the database.
Clone the model into a new, non-existing instance without raising any events.
Get the database connection for the model.
Get the current connection name for the model.
Set the connection associated with the model.
Resolve a connection instance.
Get the connection resolver instance.
Unset the connection resolver for models.
Get the table associated with the model.
Set the table associated with the model.
Get the primary key for the model.
Set the primary key for the model.
Get the table qualified key name.
Get the auto-incrementing key type.
Set the data type for the primary key.
Get the value indicating whether the IDs are incrementing.
Set whether IDs are incrementing.
Get the value of the model's primary key.
Get the queueable identity for the entity.
Get the queueable relationships for the entity.
Get the queueable connection for the entity.
Get the value of the model's route key.
Get the route key for the model.
Retrieve the model for a bound value.
Retrieve the model for a bound value.
Retrieve the child model for a bound value.
Retrieve the child model for a bound value.
Retrieve the child model query for a bound value.
Retrieve the child route model binding relationship name for the given child type.
Retrieve the model for a bound value.
Get the default foreign key name for the model.
Get the number of models to return per page.
Set the number of models to return per page.
Determine if lazy loading is disabled.
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.
Dynamically retrieve attributes on the model.
Dynamically set attributes on the model.
Determine if the given attribute exists.
Get the value for a given offset.
Set the value for a given offset.
Unset the value for a given offset.
Determine if an attribute or relation exists on the model.
Unset an attribute on the model.
Handle dynamic method calls into the model.
Handle dynamic static method calls into the model.
Convert the model to its string representation.
Indicate that the object's string representation should be escaped when __toString is invoked.
Prepare the object for serialization.
When a model is being unserialized, check if it needs to be booted.
Details
array
attributesToArray()
Convert the model's attributes to an array.
protected array
addDateAttributesToArray(array $attributes)
Add the date attributes to the attributes array.
protected array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)
Add the mutated attributes to the attributes array.
protected array
addCastAttributesToArray(array $attributes, array $mutatedAttributes)
Add the casted attributes to the attributes array.
protected array
getArrayableAttributes()
Get an attribute array of all arrayable attributes.
protected array
getArrayableAppends()
Get all of the appendable values that are arrayable.
array
relationsToArray()
Get the model's relationships in array form.
protected array
getArrayableRelations()
Get an attribute array of all arrayable relations.
protected array
getArrayableItems(array $values)
Get an attribute array of all arrayable values.
mixed
getAttribute(string $key)
Get an attribute from the model.
protected null
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).
protected 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.
protected mixed
handleLazyLoadingViolation(string $key)
Handle a lazy loading violation.
protected mixed
getRelationshipFromMethod(string $method)
Get a relationship value from a method.
bool
hasGetMutator(string $key)
Determine if a get mutator exists for an attribute.
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.
$this
mergeCasts(array $casts)
Merge new casts with existing casts on the model.
protected mixed
castAttribute(string $key, mixed $value)
Cast an attribute to a native PHP type.
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 string
getCastType(string $key)
Get the type of cast for a model attribute.
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.
protected bool
isDecimalCast(string $cast)
Determine if the cast type is a decimal cast.
mixed
setAttribute(string $key, mixed $value)
Set a given attribute on the model.
bool
hasSetMutator(string $key)
Determine if a set mutator exists for an attribute.
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.
$this
fillJsonAttribute(string $key, mixed $value)
Set a given JSON attribute on the model.
protected void
setClassCastableAttribute(string $key, mixed $value)
Set the value of a class castable attribute.
protected void
setEnumCastableAttribute(string $key, UnitEnum|string|int $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(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.
protected string
castAttributeAsJson(string $key, mixed $value)
Cast the given attribute to JSON.
protected string
asJson(mixed $value)
Encode the given value as JSON.
mixed
fromJson(string $value, bool $asObject = false)
Decode the given JSON back into an array or object.
mixed
fromEncryptedString(string $value)
Decrypt the given encrypted string.
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.
mixed
fromFloat(mixed $value)
Decode the given float.
protected string
asDecimal(float|string $value, int $decimals)
Return a decimal as string.
protected Carbon
asDate(mixed $value)
Return a timestamp as DateTime object with time set to 00:00:00.
protected Carbon
asDateTime(mixed $value)
Return a timestamp as DateTime object.
protected bool
isStandardDateFormat(string $value)
Determine if the given value is a standard date format.
string|null
fromDateTime(mixed $value)
Convert a DateTime to a storable string.
protected int
asTimestamp(mixed $value)
Return a timestamp as unix timestamp.
protected string
serializeDate(DateTimeInterface $date)
Prepare a date for array / JSON serialization.
array
getDates()
Get the attributes that should be converted to dates.
string
getDateFormat()
Get the format for database stored dates.
$this
setDateFormat(string $format)
Set the date format used by the model.
bool
hasCast(string $key, array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
array
getCasts()
Get the casts array.
protected bool
isDateCastable(string $key)
Determine whether a value is Date / DateTime castable for inbound manipulation.
protected bool
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
isEnumCastable(string $key)
Determine if the given key is cast using an enum.
protected bool
isClassDeviable(string $key)
Determine if the key is deviable using a custom class.
protected bool
isClassSerializable(string $key)
Determine if the key is serializable using a custom class.
protected mixed
resolveCasterClass(string $key)
Resolve the custom caster class for a given key.
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
mergeAttributesFromClassCasts()
Merge the cast class 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.
array
getAttributes()
Get all of the current attributes on the model.
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.
array
only(array|mixed $attributes)
Get a subset of the model's attributes.
$this
syncOriginal()
Sync the original attributes with the current.
$this
syncOriginalAttribute(string $attribute)
Sync a single original attribute with its current value.
$this
syncOriginalAttributes(array|string $attributes)
Sync multiple original attribute with their current values.
$this
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.
$this
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.
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.
array
getDirty()
Get the attributes that have been changed since the last sync.
protected 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.
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.
$this
append(array|string $attributes)
Append attributes to query when building a query.
array
getAppends()
Get the accessors that are being appended to model arrays.
$this
setAppends(array $appends)
Set the accessors to append to model arrays.
bool
hasAppended(string $attribute)
Return whether the accessor attribute has been appended.
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 protected array
getMutatorMethods(mixed $class)
Get all of the attribute mutator methods.
static protected 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.
protected void
registerObserver(object|string $class)
Register a single observer with the model.
array
getObservableEvents()
Get the observable event names.
$this
setObservableEvents(array $observables)
Set the observable event names.
void
addObservableEvents(array|mixed $observables)
Add an observable event name.
void
removeObservableEvents(array|mixed $observables)
Remove an observable event name.
static protected void
registerModelEvent(string $event, QueuedClosure|Closure|string|array $callback)
Register a model event with the dispatcher.
protected mixed
fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
protected mixed|null
fireCustomModelEvent(string $event, string $method)
Fire a custom model event for the given event.
protected mixed
filterModelEventResults(mixed $result)
Filter the model event results.
static void
retrieved(QueuedClosure|Closure|string|array $callback)
Register a retrieved model event with the dispatcher.
static void
saving(QueuedClosure|Closure|string|array $callback)
Register a saving model event with the dispatcher.
static void
saved(QueuedClosure|Closure|string|array $callback)
Register a saved model event with the dispatcher.
static void
updating(QueuedClosure|Closure|string|array $callback)
Register an updating model event with the dispatcher.
static void
updated(QueuedClosure|Closure|string|array $callback)
Register an updated model event with the dispatcher.
static void
creating(QueuedClosure|Closure|string|array $callback)
Register a creating model event with the dispatcher.
static void
created(QueuedClosure|Closure|string|array $callback)
Register a created model event with the dispatcher.
static void
replicating(QueuedClosure|Closure|string|array $callback)
Register a replicating model event with the dispatcher.
static void
deleting(QueuedClosure|Closure|string|array $callback)
Register a deleting model event with the dispatcher.
static void
deleted(QueuedClosure|Closure|string|array $callback)
Register a deleted model event with the dispatcher.
static void
flushEventListeners()
Remove all the event listeners for the model.
static Dispatcher
getEventDispatcher()
Get the event dispatcher instance.
static void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
static void
unsetEventDispatcher()
Unset the event dispatcher for models.
static mixed
withoutEvents(callable $callback)
Execute a callback without firing any model events for any model type.
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|string $scope)
Determine if a model has a global scope.
static Scope|Closure|null
getGlobalScope(Scope|string $scope)
Get a global scope registered with the model.
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.
mixed
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.
HasOne
hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null)
Define a one-to-one relationship.
protected HasOne
newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasOne relationship.
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.
protected HasOneThrough
newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)
Instantiate a new HasOneThrough relationship.
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.
protected MorphOne
newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphOne relationship.
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.
protected BelongsTo
newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)
Instantiate a new BelongsTo relationship.
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.
protected MorphTo
morphEagerTo(string $name, string $type, string $id, string $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
protected MorphTo
morphInstanceTo(string $target, string $name, string $type, string $id, string $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
protected MorphTo
newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation)
Instantiate a new MorphTo relationship.
static string
getActualClassNameForMorph(string $class)
Retrieve the actual class name for a given morph class.
protected string
guessBelongsToRelation()
Guess the "belongs to" relationship name.
PendingHasThroughRelationship
through(string|HasMany|HasOne $relationship)
Create a pending has-many-through or has-one-through relationship.
HasMany
hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null)
Define a one-to-many relationship.
protected HasMany
newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)
Instantiate a new HasMany relationship.
HasManyThrough
hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null)
Define a has-many-through relationship.
protected HasManyThrough
newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)
Instantiate a new HasManyThrough relationship.
MorphMany
morphMany(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null)
Define a polymorphic one-to-many relationship.
protected MorphMany
newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)
Instantiate a new MorphMany relationship.
BelongsToMany
belongsToMany(string $related, string|Model>|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.
protected BelongsToMany
newBelongsToMany(Builder $query, Model $parent, string|Model> $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null)
Instantiate a new BelongsToMany relationship.
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.
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.
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.
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.
bool
touches(string $relation)
Determine if the model touches a given relation.
void
touchOwners()
Touch the owning relations of the model.
protected array
getMorphs(string $name, string $type, string $id)
Get the polymorphic relationship columns.
string
getMorphClass()
Get the class name for polymorphic relations.
protected mixed
newRelatedInstance(string $class)
Create a new model instance for a related model.
protected mixed
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.
$this
setRelation(string $relation, mixed $value)
Set the given relationship on the model.
$this
unsetRelation(string $relation)
Unset a loaded relationship.
$this
setRelations(array $relations)
Set the entire relations array on the model.
$this
withoutRelations()
Duplicate the instance and unset all the loaded relations.
$this
unsetRelations()
Unset all the loaded relations for the instance.
array
getTouchedRelations()
Get the relationships that are touched on save.
$this
setTouchedRelations(array $touches)
Set the relationships that are touched on save.
bool
touch(string|null $attribute = null)
Update the model's update timestamp.
bool
touchQuietly(string|null $attribute = null)
Update the model's update timestamp without raising any events.
$this
updateTimestamps()
Update the creation and update timestamps.
$this
setCreatedAt(mixed $value)
Set the value of the "created at" attribute.
$this
setUpdatedAt(mixed $value)
Set the value of the "updated at" attribute.
Carbon
freshTimestamp()
Get a fresh timestamp for the model.
string
freshTimestampString()
Get a fresh timestamp for the model.
bool
usesTimestamps()
Determine if the model uses timestamps.
string|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
newUniqueId()
Generate a new key for the model.
array
uniqueIds()
Get the columns that should receive a unique identifier.
string[]
getHidden()
Get the hidden attributes for the model.
$this
setHidden(array $hidden)
Set the hidden attributes for the model.
string[]
getVisible()
Get the visible attributes for the model.
$this
setVisible(array $visible)
Set the visible attributes for the model.
$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.
string[]
getFillable()
Get the fillable attributes for the model.
$this
fillable(array $fillable)
Set the fillable attributes for the model.
$this
mergeFillable(array $fillable)
Merge new fillable attributes with existing fillable attributes on the model.
string[]
getGuarded()
Get the guarded attributes for the model.
$this
guard(array $guarded)
Set the guarded attributes for the model.
$this
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.
protected bool
isGuardableColumn(string $key)
Determine if the given column is a valid, guardable column.
bool
totallyGuarded()
Determine if the model is totally guarded.
protected array
fillableFromArray(array $attributes)
Get the fillable attributes of a given array.
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 void
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
void
__construct(array $attributes = [])
Create a new Eloquent model instance.
protected void
bootIfNotBooted()
Check if the model needs to be booted and if so, do it.
static protected void
booting()
Perform any actions required before the model boots.
static protected void
boot()
Bootstrap the model and its traits.
static protected void
bootTraits()
Boot all of the bootable traits on the model.
protected void
initializeTraits()
Initialize any initializable traits on the model.
static protected void
booted()
Perform any actions required after the model boots.
static void
clearBootedModels()
Clear the list of booted models so they will be re-booted.
static void
withoutTouching(callable $callback)
Disables relationship model touching for the current class during given callback scope.
static void
withoutTouchingOn(array $models, callable $callback)
Disables relationship model touching for the given model classes during given callback scope.
static bool
isIgnoringTouch(string|null $class = null)
Determine if the given model is ignoring touches.
static void
shouldBeStrict(bool $shouldBeStrict = true)
Indicate that models should prevent lazy loading, silently discarding attributes, and accessing missing attributes.
static void
preventLazyLoading(bool $value = true)
Prevent model relationships from being lazy loaded.
static void
handleLazyLoadingViolationUsing(callable|null $callback)
Register a callback that is responsible for handling lazy loading violations.
static void
preventSilentlyDiscardingAttributes(bool $value = true)
Prevent non-fillable attributes from being silently discarded.
static void
handleDiscardedAttributeViolationUsing(callable|null $callback)
Register a callback that is responsible for handling discarded attribute violations.
static void
preventAccessingMissingAttributes(bool $value = true)
Prevent accessing missing attributes on retrieved models.
static void
handleMissingAttributeViolationUsing(callable|null $callback)
Register a callback that is responsible for handling missing attribute violations.
static mixed
withoutBroadcasting(callable $callback)
Execute a callback without broadcasting any model events for all model types.
$this
fill(array $attributes)
Fill the model with an array of attributes.
$this
forceFill(array $attributes)
Fill the model with an array of attributes. Force mass assignment.
string
qualifyColumn(string $column)
Qualify the given column name by the model's table.
array
qualifyColumns(array $columns)
Qualify the given columns with the model's table.
Model
newInstance(array $attributes = [], bool $exists = false)
Create a new instance of the given model.
Model
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance that is existing.
static Builder
on(string|null $connection = null)
Begin querying the model on a given connection.
static Builder
onWriteConnection()
Begin querying the model on the write connection.
static Collection<int,static>
all(array|string $columns = ['*'])
Get all of the models from the database.
static Builder
with(array|string $relations)
Begin querying a model with eager loading.
$this
load(array|string $relations)
Eager load relations on the model.
$this
loadMorph(string $relation, array $relations)
Eager load relationships on the polymorphic relation of a model.
$this
loadMissing(array|string $relations)
Eager load relations on the model if they are not already eager loaded.
$this
loadAggregate(array|string $relations, string $column, string|null $function = null)
Eager load relation's column aggregations on the model.
$this
loadCount(array|string $relations)
Eager load relation counts on the model.
$this
loadMax(array|string $relations, string $column)
Eager load relation max column values on the model.
$this
loadMin(array|string $relations, string $column)
Eager load relation min column values on the model.
$this
loadSum(array|string $relations, string $column)
Eager load relation's column summations on the model.
$this
loadAvg(array|string $relations, string $column)
Eager load relation average column values on the model.
$this
loadExists(array|string $relations)
Eager load related model existence values on the model.
$this
loadMorphAggregate(string $relation, array $relations, string $column, string|null $function = null)
Eager load relationship column aggregation on the polymorphic relation of a model.
$this
loadMorphCount(string $relation, array $relations)
Eager load relationship counts on the polymorphic relation of a model.
$this
loadMorphMax(string $relation, array $relations, string $column)
Eager load relationship max column values on the polymorphic relation of a model.
$this
loadMorphMin(string $relation, array $relations, string $column)
Eager load relationship min column values on the polymorphic relation of a model.
$this
loadMorphSum(string $relation, array $relations, string $column)
Eager load relationship column summations on the polymorphic relation of a model.
$this
loadMorphAvg(string $relation, array $relations, string $column)
Eager load relationship average column values on the polymorphic relation of a model.
protected int
increment(string $column, float|int $amount = 1, array $extra = [])
Increment a column's value by a given amount.
protected int
decrement(string $column, float|int $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
protected int
incrementOrDecrement(string $column, float|int $amount, array $extra, string $method)
Run the increment or decrement method on the model.
bool
update(array $attributes = [], array $options = [])
Update the model in the database.
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
push()
Save the model and all of its relationships.
bool
pushQuietly()
Save the model and all of its relationships without raising any events to the parent model.
bool
saveQuietly(array $options = [])
Save the model to the database without raising any events.
bool
save(array $options = [])
Save the model to the database.
bool
saveOrFail(array $options = [])
Save the model to the database within a transaction.
protected void
finishSave(array $options)
Perform any actions that are necessary after the model is saved.
protected bool
performUpdate(Builder $query)
Perform a model update operation.
protected mixed
getKeyForSelectQuery()
Get the primary key value for a select query.
protected mixed
getKeyForSaveQuery()
Get the primary key value for a save query.
protected bool
performInsert(Builder $query)
Perform a model insert operation.
protected void
insertAndSetId(Builder $query, array $attributes)
Insert the given attributes and set the ID on the model.
static int
destroy(Collection|array|int|string $ids)
Destroy the models for the given IDs.
bool|null
delete()
Delete the model from the database.
bool
deleteQuietly()
Delete the model from the database without raising any events.
bool|null
deleteOrFail()
Delete the model from the database within a transaction.
bool|null
forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when the trait is missing.
protected void
performDeleteOnModel()
Perform the actual delete query on this model instance.
static Builder
query()
Begin querying the model.
Builder
newQuery()
Get a new query builder for the model's table.
Builder|Model
newModelQuery()
Get a new query builder that doesn't have any global scopes or eager loading.
Builder
newQueryWithoutRelationships()
Get a new query builder with no relationships loaded.
Builder
registerGlobalScopes(Builder $builder)
Register the global scopes for this builder instance.
Builder
newQueryForRestoration(array|int $ids)
Get a new query to restore one or more models by their queueable IDs.
protected Builder
newBaseQueryBuilder()
Get a new query builder instance for the connection.
Collection
newCollection(array $models = [])
Create a new Eloquent Collection instance.
Pivot
newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)
Create a new pivot model instance.
bool
hasNamedScope(string $scope)
Determine if the model has a given scope.
mixed
callNamedScope(string $scope, array $parameters = [])
Apply the given named scope if possible.
toArray()
Convert the model instance to an array.
string
toJson(int $options = 0)
Convert the model instance to JSON.
mixed
jsonSerialize()
Convert the object into something JSON serializable.
Model|null
fresh(array|string $with = [])
Reload a fresh model instance from the database.
$this
refresh()
Reload the current model instance with fresh attributes from the database.
Model
replicate(array $except = null)
Clone the model into a new, non-existing instance.
Model
replicateQuietly(array $except = null)
Clone the model into a new, non-existing instance without raising any events.
bool
is(Model|null $model)
Determine if two models have the same ID and belong to the same table.
bool
isNot(Model|null $model)
Determine if two models are not the same.
Connection
getConnection()
Get the database connection for the model.
string|null
getConnectionName()
Get the current connection name for the model.
$this
setConnection(string|null $name)
Set the connection associated with the model.
static Connection
resolveConnection(string|null $connection = null)
Resolve a connection instance.
static ConnectionResolverInterface|null
getConnectionResolver()
Get the connection resolver instance.
static void
setConnectionResolver(ConnectionResolverInterface $resolver)
Set the connection resolver instance.
static void
unsetConnectionResolver()
Unset the connection resolver for models.
string
getTable()
Get the table associated with the model.
$this
setTable(string $table)
Set the table associated with the model.
string
getKeyName()
Get the primary key for the model.
$this
setKeyName(string $key)
Set the primary key for the model.
string
getQualifiedKeyName()
Get the table qualified key name.
string
getKeyType()
Get the auto-incrementing key type.
$this
setKeyType(string $type)
Set the data type for the primary key.
bool
getIncrementing()
Get the value indicating whether the IDs are incrementing.
$this
setIncrementing(bool $value)
Set whether IDs are incrementing.
mixed
getKey()
Get the value of the model's primary key.
mixed
getQueueableId()
Get the queueable identity for the entity.
array
getQueueableRelations()
Get the queueable relationships for the entity.
string|null
getQueueableConnection()
Get the queueable connection for the entity.
mixed
getRouteKey()
Get the value of the model's route key.
string
getRouteKeyName()
Get the route key for the model.
Model|null
resolveRouteBinding(mixed $value, 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 Relation
resolveChildRouteBindingQuery(string $childType, mixed $value, string|null $field)
Retrieve the child model query for a bound value.
protected string
childRouteBindingRelationshipName(string $childType)
Retrieve the child route model binding relationship name for the given child type.
Relation
resolveRouteBindingQuery(Model|Builder|Relation $query, mixed $value, string|null $field = null)
Retrieve the model for a bound value.
string
getForeignKey()
Get the default foreign key name for the model.
int
getPerPage()
Get the number of models to return per page.
$this
setPerPage(int $perPage)
Set the number of models to return per page.
static bool
preventsLazyLoading()
Determine if lazy loading is disabled.
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.
string
broadcastChannel()
Get the broadcast channel name that is associated with the given entity.
mixed
__get(string $key)
Dynamically retrieve attributes on the model.
void
__set(string $key, mixed $value)
Dynamically set attributes on the model.
bool
offsetExists(mixed $offset)
Determine if the given attribute exists.
mixed
offsetGet(mixed $offset)
Get the value for a given offset.
void
offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
void
offsetUnset(mixed $offset)
Unset the value for a given offset.
bool
__isset(string $key)
Determine if an attribute or relation exists on the model.
void
__unset(string $key)
Unset an attribute on the model.
mixed
__call(string $method, array $parameters)
Handle dynamic method calls into the model.
static mixed
__callStatic(string $method, array $parameters)
Handle dynamic static method calls into the model.
string
__toString()
Convert the model to its string representation.
$this
escapeWhenCastingToString(bool $escape = true)
Indicate that the object's string representation should be escaped when __toString is invoked.
array
__sleep()
Prepare the object for serialization.
void
__wakeup()
When a model is being unserialized, check if it needs to be booted.