Documentation

Role extends Model
in package
Uses Validation

Role model

Table of Contents

CREATED_AT  = 'created_at'
The name of the "created at" column.
UPDATED_AT  = 'updated_at'
The name of the "updated at" column.
$attachMany  : mixed
protected $attachMany = [ 'pictures' => ['October\Rain\Database\Attach\File', 'name'=> 'imageable'] ];
$attachOne  : mixed
protected $attachOne = [ 'picture' => ['October\Rain\Database\Attach\File', 'public' => false] ];
$belongsTo  : mixed
protected $belongsTo = [ 'parent' => ['Category', 'key' => 'parent_id'] ];
$belongsToMany  : mixed
protected $belongsToMany = [ 'groups' => ['Group', 'table'=> 'join_groups_users'] ];
$duplicateCache  : bool
$exists  : bool
Indicates if the model exists.
$hasMany  : array<string|int, mixed>
$hasManyThrough  : mixed
protected $attachMany = [ 'pictures' => ['Picture', 'name'=> 'imageable'] ];
$hasOne  : mixed
protected $hasOne = [ 'owner' => ['User', 'key' => 'user_id'] ];
$implement  : array<string|int, mixed>
$incrementing  : bool
Indicates if the IDs are auto-incrementing.
$manyMethods  : array<string|int, mixed>
The many to many relationship methods.
$morphedByMany  : mixed
$morphMany  : mixed
protected $morphMany = [ 'log' => ['History', 'name' => 'user'] ];
$morphOne  : mixed
protected $morphOne = [ 'log' => ['History', 'name' => 'user'] ];
$morphTo  : mixed
protected $morphTo = [ 'pictures' => [] ];
$morphToMany  : mixed
protected $morphToMany = [ 'tag' => ['Tag', 'table' => 'tagables', 'name' => 'tagable'] ];
$rules  : array<string|int, mixed>
$sessionKey  : string
$snakeAttributes  : bool
Indicates whether attributes are snake cased on arrays.
$timestamps  : bool
Indicates if the model should be timestamped.
$wasRecentlyCreated  : bool
Indicates if the model was inserted during the current request lifecycle.
$allowedPermissionsValues  : array<string|int, mixed>
$appends  : array<string|int, mixed>
The accessors to append to the model's array form.
$attributes  : array<string|int, mixed>
The model's attributes.
$booted  : array<string|int, mixed>
The array of booted models.
$casts  : array<string|int, mixed>
The attributes that should be cast to native types.
$changes  : array<string|int, mixed>
The changed model attributes.
$connection  : string
The connection name for the model.
$dateFormat  : string
The storage format of the model's date columns.
$dates  : array<string|int, mixed>
The attributes that should be mutated to dates.
$dispatcher  : Dispatcher
The event dispatcher instance.
$dispatchesEvents  : array<string|int, mixed>
The event map for the model.
$emitterEventCollection  : array<string|int, mixed>
$emitterEventSorted  : array<string|int, mixed>
$emitterSingleEventCollection  : array<string|int, mixed>
$eventsBooted  : array<string|int, mixed>
$extendableCallbacks  : array<string|int, mixed>
$extendableGuardProperties  : bool
$extendableStaticMethods  : array<string|int, mixed>
$extensionData  : array<string|int, mixed>
$fillable  : array<string|int, mixed>
The attributes that are mass assignable.
$globalScopes  : array<string|int, mixed>
The array of global scopes on the model.
$guardableColumns  : array<string|int, mixed>
The actual columns that exist on the database and can be guarded.
$guarded  : array<string|int, mixed>
$hidden  : array<string|int, mixed>
The attributes that should be hidden for serialization.
$jsonable  : array<string|int, mixed>
$keyType  : string
The "type" of the auto-incrementing ID.
$mutatorCache  : array<string|int, mixed>
The cache of the mutated attributes for each class.
$observables  : array<string|int, mixed>
User exposed observable events.
$original  : array<string|int, mixed>
The model attribute's original state.
$perPage  : int
The number of models to return for pagination.
$primaryKey  : string
The primary key for the model.
$relations  : array<string|int, mixed>
The loaded relationships for the model.
$relationTypes  : array<string|int, mixed>
$resolver  : ConnectionResolverInterface
The connection resolver instance.
$table  : string
$touches  : array<string|int, mixed>
The relationships that should be touched on save.
$unguarded  : bool
Indicates if all mass assignment is enabled.
$validationDefaultAttrNames  : array<string|int, mixed>
$validationErrors  : MessageBag
$visible  : array<string|int, mixed>
The attributes that should be visible in serialization.
$with  : array<string|int, mixed>
The relations to eager load on every query.
$withCount  : array<string|int, mixed>
The relationship counts that should be eager loaded on every query.
__call()  : mixed
Handle dynamic method calls into the model.
__callStatic()  : mixed
Handle dynamic static method calls into the method.
__construct()  : void
Create a new Eloquent model instance.
__get()  : mixed
Dynamically retrieve attributes on the model.
__isset()  : bool
Determine if an attribute or relation exists on the model.
__set()  : void
Dynamically set attributes on the model.
__toString()  : string
Convert the model to its string representation.
__unset()  : void
Unset an attribute on the model.
__wakeup()  : void
When a model is being unserialized, check if it needs to be booted.
addCasts()  : void
Add attribute casts for the model.
addDateAttribute()  : void
Adds a datetime attribute to convert to an instance of Carbon/DateTime object.
addDynamicMethod()  : mixed
Programmatically adds a method to the extendable class
addDynamicProperty()  : mixed
Programmatically adds a property to the extendable class
addFillable()  : void
Add fillable attributes for the model.
addGlobalScope()  : mixed
Register a new global scope on the model.
addHidden()  : void
Add hidden attributes for the model.
addJsonable()  : void
Add jsonable attributes for the model.
addObservableEvents()  : void
Add an observable event name.
addVisible()  : void
Add visible attributes for the model.
all()  : Collection|array<string|int, static>
Get all of the models from the database.
alwaysPush()  : bool
Pushes the first level of relations even if the parent model has no changes.
append()  : $this
Append attributes to query when building a query.
asExtension()  : mixed
Short hand for `getClassExtension()` method, except takes the short extension name, example:
attachMany()  : MorphMany
Define an attachment one-to-many relationship.
attachOne()  : MorphOne
Define an attachment one-to-one relationship.
attributesToArray()  : array<string|int, mixed>
Convert the model's attributes to an array.
belongsTo()  : BelongsTo
Define an inverse one-to-one or many relationship.
belongsToMany()  : BelongsToMany
Define a many-to-many relationship.
bindDeferred()  : mixed
Bind a deferred relationship to the supplied record.
bindEvent()  : self
Create a new event binding.
bindEventOnce()  : self
Create a new event binding that fires once only
bootValidation()  : void
Boot the validation trait for this model.
cacheMutatedAttributes()  : void
Extract and cache all the mutated attributes of a class.
cancelDeferred()  : mixed
Cancel all deferred bindings to this model.
clearBootedModels()  : void
Clear the list of booted models so they will be re-booted.
clearExtendedClasses()  : void
Clear the list of extended classes so they will be re-extended.
commitDeferred()  : mixed
Commit all deferred bindings to this model.
create()  : Model|static
Save a new model and return the instance.
created()  : void
Register a created model event with the dispatcher.
creating()  : void
Register a creating model event with the dispatcher.
delete()  : bool|null
Delete the model from the database.
deleted()  : void
Register a deleted model event with the dispatcher.
deleting()  : void
Register a deleting model event with the dispatcher.
destroy()  : int
Destroy the models for the given IDs.
errors()  : MessageBag
Get validation error message collection for the Model
extend()  : mixed
Extend this object properties upon construction.
extendableCall()  : mixed
Magic method for `__call()`
extendableCallStatic()  : mixed
Magic method for `__callStatic()`
extendableConstruct()  : mixed
This method should be called as part of the constructor.
extendableExtendCallback()  : void
Helper method for `::extend()` static method
extendableGet()  : string
Magic method for `__get()`
extendableSet()  : string
Magic method for `__set()`
extendClassWith()  : void
Dynamically extend a class with a specified behavior
fetched()  : void
Create a new native event for handling afterFetch().
fetching()  : void
Create a new native event for handling beforeFetch().
fill()  : $this
Fill the model with an array of attributes.
fillable()  : $this
Set the fillable attributes for the model.
fillJsonAttribute()  : $this
Set a given JSON attribute on the model.
fireEvent()  : array<string|int, mixed>
Fire an event and call the listeners.
flushDuplicateCache()  : void
Flush the memory cache.
flushEventListeners()  : void
Remove all of the event listeners for the model.
forceDelete()  : bool|null
Force a hard delete on a soft deleted model.
forceFill()  : $this
Fill the model with an array of attributes. Force mass assignment.
forceSave()  : bool
Force save the model even if validation fails.
fresh()  : static|null
Reload a fresh model instance from the database.
freshTimestamp()  : Carbon
Get a fresh timestamp for the model.
freshTimestampString()  : string
Get a fresh timestamp for the model.
fromDateTime()  : string
Convert a DateTime to a storable string.
fromJson()  : mixed
Decode the given JSON back into an array or object.
getActualClassNameForMorph()  : string
Retrieve the actual class name for a given morph class.
getAttribute()  : mixed
Get an attribute from the model.
getAttributes()  : array<string|int, mixed>
Get all of the current attributes on the model.
getAttributeValue()  : mixed
Get a plain attribute (not a relationship).
getCasts()  : array<string|int, mixed>
Get the casts array.
getChanges()  : array<string|int, mixed>
Get the attributes that were changed.
getClassExtension()  : mixed
Returns a behavior object from an extendable class, example:
getClassMethods()  : array<string|int, mixed>
Get a list of class methods, extension equivalent of get_class_methods()
getConnection()  : Connection
Get the database connection for the model.
getConnectionName()  : string
Get the current connection name for the model.
getConnectionResolver()  : ConnectionResolverInterface
Get the connection resolver instance.
getCreatedAtColumn()  : string
Get the name of the "created at" column.
getDates()  : array<string|int, mixed>
Get the attributes that should be converted to dates.
getDirty()  : array<string|int, mixed>
Get the attributes that have been changed since last sync.
getDynamicProperties()  : array<string|int, mixed>
Returns all dynamic properties and their values
getEventDispatcher()  : Dispatcher
Get the event dispatcher instance.
getFillable()  : array<string|int, mixed>
Get the fillable attributes for the model.
getForeignKey()  : string
Get the default foreign key name for the model.
getGlobalScope()  : Scope|Closure|null
Get a global scope registered with the model.
getGlobalScopes()  : array<string|int, mixed>
Get the global scopes for this class instance.
getGuarded()  : array<string|int, mixed>
Get the guarded attributes for the model.
getHidden()  : array<string|int, mixed>
Get the hidden attributes for the model.
getIncrementing()  : bool
Get the value indicating whether the IDs are incrementing.
getJsonable()  : array<string|int, mixed>
Get the jsonable attributes name
getKey()  : mixed
Get the value of the model's primary key.
getKeyName()  : string
Get the primary key for the model.
getKeyType()  : string
Get the auto-incrementing key type.
getMorphClass()  : string
Get the class name for polymorphic relations.
getMutatedAttributes()  : array<string|int, mixed>
Get the mutated attributes for a given instance.
getObservableEvents()  : array<string|int, mixed>
Get the observable event names.
getOriginal()  : mixed|array<string|int, mixed>
Get the model's original attribute values.
getPerPage()  : int
Get the number of models to return per page.
getQualifiedKeyName()  : string
Get the table qualified key name.
getQueueableConnection()  : mixed
Get the queueable connection for the entity.
getQueueableId()  : mixed
Get the queueable identity for the entity.
getRelation()  : mixed
Get a specified relationship.
getRelationDefinition()  : array<string|int, mixed>
Returns relationship details from a supplied name.
getRelationDefinitions()  : array<string|int, mixed>
Returns relationship details for all relations defined on this model.
getRelations()  : array<string|int, mixed>
Get all the loaded relations for the instance.
getRelationType()  : string
Returns a relationship type based on a supplied name.
getRelationValue()  : mixed
Get a relationship.
getRouteKey()  : mixed
Get the value of the model's route key.
getRouteKeyName()  : string
Get the route key for the model.
getTable()  : string
Get the table associated with the model.
getTouchedRelations()  : array<string|int, mixed>
Get the relationships that are touched on save.
getUpdatedAtColumn()  : string
Get the name of the "updated at" column.
getVisible()  : array<string|int, mixed>
Get the visible attributes for the model.
guard()  : $this
Set the guarded attributes for the model.
hasAccess()  : bool
See if a role has access to the passed permission(s).
hasAnyAccess()  : bool
Returns if the user has access to any of the given permissions.
hasCast()  : bool
Determine whether an attribute should be cast to a native type.
hasGetMutator()  : bool
Determine if a get mutator exists for an attribute.
hasGlobalScope()  : bool
Determine if a model has a global scope.
hasMany()  : HasMany
Define a one-to-many relationship.
hasManyThrough()  : HasManyThrough
Define a has-many-through relationship.
hasOne()  : HasOne
Define a one-to-one relationship.
hasRelation()  : bool
Checks if model has a relationship by supplied name.
hasSetMutator()  : bool
Determine if a set mutator exists for an attribute.
is()  : bool
Determine if two models have the same ID and belong to the same table.
isAttributeRequired()  : bool
Determines if an attribute is required based on the validation rules.
isClassExtendedWith()  : bool
Check if extendable class is extended with a behavior object
isClean()  : bool
Determine if the model or given attribute(s) have remained the same.
isDeferrable()  : mixed
Returns true if a relation exists and can be deferred.
isDirty()  : bool
Determine if the model or given attribute(s) have been modified.
isFillable()  : bool
Determine if the given attribute may be mass assigned.
isGuarded()  : bool
Determine if the given key is guarded.
isJsonable()  : array<string|int, mixed>
Checks if an attribute is jsonable or not.
isNot()  : bool
Determine if two models are not the same.
isRelationPushable()  : bool
Determines whether the specified relation should be saved when push() is called instead of save() on the model. Default: true.
isUnguarded()  : bool
Determine if current state is "unguarded".
joiningTable()  : string
Get the joining table name for a many-to-many relation.
jsonable()  : $this
Set the jsonable attributes for the model.
jsonSerialize()  : array<string|int, mixed>
Convert the object into something JSON serializable.
load()  : $this
Eager load relations on the model.
loadMissing()  : $this
Eager load relations on the model if they are not already eager loaded.
make()  : Model|static
Create a new model and return the instance.
makeHidden()  : $this
Make the given, typically visible, attributes hidden.
makeRelation()  : string
Returns a relation class object
makeVisible()  : $this
Make the given, typically hidden, attributes visible.
methodExists()  : bool
Checks if a method exists, extension equivalent of method_exists()
morphedByMany()  : MorphToMany
Define a polymorphic, inverse many-to-many relationship.
morphMany()  : MorphMany
Define a polymorphic one-to-many relationship.
morphOne()  : MorphOne
Define a polymorphic one-to-one relationship.
morphTo()  : MorphTo
Define a polymorphic, inverse one-to-one or many relationship.
morphToMany()  : MorphToMany
Define a polymorphic many-to-many relationship.
newCollection()  : Collection
Create a new Eloquent Collection instance.
newEloquentBuilder()  : Builder|static
Create a new Eloquent query builder for the model.
newFromBuilder()  : static
Create a new model instance that is existing.
newInstance()  : static
Create a new instance of the given model.
newModelQuery()  : Builder|static
Get a new query builder that doesn't have any global scopes or eager loading.
newPivot()  : Pivot
Create a new pivot model instance.
newQuery()  : Builder
Get a new query builder for the model's table.
newQueryForRestoration()  : Builder
Get a new query to restore one or more models by their queueable IDs.
newQueryWithoutRelationships()  : Builder
Get a new query builder with no relationships loaded.
newQueryWithoutScope()  : Builder
Get a new query instance without a given scope.
newQueryWithoutScopes()  : Builder|static
Get a new query builder that doesn't have any global scopes.
newRelationPivot()  : Pivot
Create a pivot model instance specific to a relation.
observe()  : void
Register an observer with the Model.
offsetExists()  : bool
Determine if the given attribute exists.
offsetGet()  : mixed
Get the value for a given offset.
offsetSet()  : void
Set the value for a given offset.
offsetUnset()  : void
Unset the value for a given offset.
on()  : Builder
Begin querying the model on a given connection.
only()  : array<string|int, mixed>
Get a subset of the model's attributes.
onWriteConnection()  : Builder
Begin querying the model on the write connection.
propertyExists()  : bool
Checks if a property exists, extension equivalent of `property_exists()`
push()  : bool
Save the model and all of its relationships.
qualifyColumn()  : string
Qualify the given column name by the model's table.
query()  : Builder
Begin querying the model.
refresh()  : $this
Reload the current model instance with fresh attributes from the database.
registerGlobalScopes()  : Builder
Register the global scopes for this builder instance.
reguard()  : void
Enable the mass assignment restrictions.
relationLoaded()  : bool
Determine if the given relation is loaded.
relationsToArray()  : array<string|int, mixed>
Get the model's relationships in array form.
reload()  : Model|static
Reloads the model attributes from the database.
reloadRelations()  : void
Reloads the model relationship cache.
removeObservableEvents()  : void
Remove an observable event name.
replicate()  : Model
Clone the model into a new, non-existing instance.
resolveConnection()  : Connection
Resolve a connection instance.
resolveRouteBinding()  : Model|null
Retrieve the model for a bound value.
retrieved()  : void
Register a retrieved model event with the dispatcher.
save()  : bool
Save the model to the database.
saved()  : void
Register a saved model event with the dispatcher.
saveOrFail()  : bool
Save the model to the database using transaction.
saving()  : void
Register a saving model event with the dispatcher.
setAppends()  : $this
Set the accessors to append to model arrays.
setAttribute()  : $this
Set a given attribute on the model.
setConnection()  : $this
Set the connection associated with the model.
setConnectionResolver()  : void
Set the connection resolver instance.
setCreatedAt()  : $this
Set the value of the "created at" attribute.
setDateFormat()  : $this
Set the date format used by the model.
setEventDispatcher()  : void
Set the event dispatcher instance.
setHidden()  : $this
Set the hidden attributes for the model.
setIncrementing()  : $this
Set whether IDs are incrementing.
setKeyName()  : $this
Set the primary key for the model.
setKeyType()  : $this
Set the data type for the primary key.
setObservableEvents()  : $this
Set the observable event names.
setPermissionsAttribute()  : void
Validate the permissions when set.
setPerPage()  : $this
Set the number of models to return per page.
setRawAttributes()  : $this
Set the array of model attributes. No checking is done.
setRelation()  : $this
Set the specific relationship in the model.
setRelations()  : $this
Set the entire relations array on the model.
setTable()  : $this
Set the table associated with the model.
setTouchedRelations()  : $this
Set the relationships that are touched on save.
setUpdatedAt()  : $this
Set the value of the "updated at" attribute.
setValidationAttributeName()  : void
Programatically sets the validation attribute names, will take lower priority to model defined attribute names found in `$attributeNames`.
setValidationAttributeNames()  : void
Programatically sets multiple validation attribute names.
setVisible()  : $this
Set the visible attributes for the model.
syncChanges()  : $this
Sync the changed attributes.
syncOriginal()  : $this
Sync the original attributes with the current.
syncOriginalAttribute()  : $this
Sync a single original attribute with its current value.
toArray()  : array<string|int, mixed>
Convert the model instance to an array.
toJson()  : string
Convert the model instance to JSON.
totallyGuarded()  : bool
Determine if the model is totally guarded.
touch()  : bool
Update the model's update timestamp.
touches()  : bool
Determine if the model touches a given relation.
touchOwners()  : void
Touch the owning relations of the model.
unbindDeferred()  : mixed
Unbind a deferred relationship to the supplied record.
unbindEvent()  : self
Destroys an event binding.
unguard()  : void
Disable all mass assignable restrictions.
unguarded()  : mixed
Run the given callable while being unguarded.
unsetConnectionResolver()  : void
Unset the connection resolver for models.
unsetEventDispatcher()  : void
Unset the event dispatcher for models.
update()  : bool
Update the model in the database.
updated()  : void
Register an updated model event with the dispatcher.
updating()  : void
Register an updating model event with the dispatcher.
usesTimestamps()  : bool
Determine if the model uses timestamps.
validate()  : bool
Validate the model instance
validated()  : void
Create a new native event for handling afterValidate().
validating()  : void
Create a new native event for handling beforeValidate().
wasChanged()  : bool
Determine if the model or given attribute(s) have been modified.
with()  : Builder|static
Begin querying a model with eager loading.
addCastAttributesToArray()  : array<string|int, mixed>
Add the casted attributes to the attributes array.
addDateAttributesToArray()  : array<string|int, mixed>
Add the date attributes to the attributes array.
addMutatedAttributesToArray()  : array<string|int, mixed>
Add the mutated attributes to the attributes array.
afterCreate()  : mixed
Handle the "created" model event
afterDelete()  : mixed
Handle the "deleted" model event
afterFetch()  : mixed
Handle the "fetched" model event
afterSave()  : mixed
Handle the "saved" model event
afterUpdate()  : mixed
Handle the "updated" model event
asDate()  : Carbon
Return a timestamp as DateTime object with time set to 00:00:00.
asDateTime()  : Carbon
Return a timestamp as DateTime object.
asJson()  : string
Encode the given value as JSON.
asTimestamp()  : int
Return a timestamp as unix timestamp.
beforeCreate()  : mixed
Handle the "creating" model event
beforeDelete()  : mixed
Handle the "deleting" model event
beforeFetch()  : mixed
Handle the "fetching" model event
beforeSave()  : mixed
Handle the "saving" model event
beforeUpdate()  : mixed
Handle the "updating" model event
boot()  : void
The "booting" method of the model.
bootIfNotBooted()  : void
Check if the model needs to be booted and if so, do it.
bootNicerEvents()  : mixed
Bind some nicer events to this model, in the format of method overrides.
bootTraits()  : void
Boot all of the bootable traits on the model.
castAttribute()  : mixed
Cast an attribute to a native PHP type.
castAttributeAsJson()  : string
Cast the given attribute to JSON.
commitDeferredAfter()  : mixed
Internally used method to commit all deferred bindings after saving.
commitDeferredBefore()  : mixed
Internally used method to commit all deferred bindings before saving.
commitDeferredOfType()  : mixed
Internal method for committing deferred relations.
decrement()  : int
Decrement a column's value by a given amount.
emitterEventSortEvents()  : array<string|int, mixed>
Sort the listeners for a given event by priority.
extendableIsAccessible()  : bool
Checks if a property is accessible, property equivalent of `is_callable()`
extensionExtractMethods()  : void
Extracts the available methods from a behavior and adds it to the list of callable methods.
fillableFromArray()  : array<string|int, mixed>
Get the fillable attributes of a given array.
filterModelEventResults()  : mixed
Filter the model event results.
finishSave()  : void
Perform any actions that are necessary after the model is saved.
fireCustomModelEvent()  : mixed|null
Fire a custom model event for the given event.
fireModelEvent()  : mixed
Fire the given event for the model.
getArrayableAppends()  : array<string|int, mixed>
Get all of the appendable values that are arrayable.
getArrayableAttributes()  : array<string|int, mixed>
Get an attribute array of all arrayable attributes.
getArrayableItems()  : array<string|int, mixed>
Get an attribute array of all arrayable values.
getArrayableRelations()  : array<string|int, mixed>
Get an attribute array of all arrayable relations.
getArrayAttributeByKey()  : array<string|int, mixed>
Get an array attribute or return an empty array if it is not set.
getArrayAttributeWithValue()  : $this
Get an array attribute with the given key and value set.
getAttributeFromArray()  : mixed
Get an attribute from the $attributes array.
getCastType()  : string
Get the type of cast for a model attribute.
getDateFormat()  : string
Get the format for database stored dates.
getDeferrableRelationTypes()  : array<string|int, mixed>
Returns all possible relation types that can be deferred.
getDeferredBindingRecords()  : Collection
Returns any outstanding binding records for this model.
getKeyForSaveQuery()  : mixed
Get the primary key value for a save query.
getMorphs()  : array<string|int, mixed>
Get the polymorphic relationship columns.
getMutatorMethods()  : array<string|int, mixed>
Get all of the attribute mutator methods.
getRelationCaller()  : mixed
Finds the calling function name from the stack trace.
getRelationDefaults()  : array<string|int, mixed>
Returns default relation arguments for a given type.
getRelationshipFromMethod()  : mixed
Get a relationship value from a method.
getRelationValidationValue()  : mixed
Attachments validate differently to their simple values.
getValidationAttributes()  : array<string|int, mixed>
Returns the model data used for validation.
guessBelongsToManyRelation()  : string
Get the relationship name of the belongs to many.
guessBelongsToRelation()  : string
Guess the "belongs to" relationship name.
handleRelation()  : Relation
Looks for the relation and does the correct magic as Eloquent would require inside relation methods. For more information, read the documentation of the mentioned property.
hasChanges()  : bool
Determine if the given attributes were changed.
increment()  : int
Increment a column's value by a given amount.
incrementOrDecrement()  : int
Run the increment or decrement method on the model.
incrementOrDecrementAttributeValue()  : void
Increment the underlying attribute value and sync with original.
insertAndSetId()  : void
Insert the given attributes and set the ID on the model.
isDateAttribute()  : bool
Determine if the given attribute is a date or date castable.
isDateCastable()  : bool
Determine whether a value is Date / DateTime castable for inbound manipulation.
isGuardableColumn()  : bool
Determine if the given column is a valid, guardable column.
isJsonCastable()  : bool
Determine whether a value is JSON castable for inbound manipulation.
isStandardDateFormat()  : bool
Determine if the given value is a standard date format.
makeValidator()  : Validator
Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel. Optional connection string to make the validator use a different database connection than the default connection.
morphEagerTo()  : MorphTo
Define a polymorphic, inverse one-to-one or many relationship.
morphInstanceTo()  : MorphTo
Define a polymorphic, inverse one-to-one or many relationship.
mutateAttribute()  : mixed
Get the value of an attribute using its mutator.
mutateAttributeForArray()  : mixed
Get the value of an attribute using its mutator for array conversion.
newBaseQueryBuilder()  : Builder
Get a new query builder instance for the connection.
newBelongsTo()  : BelongsTo
Instantiate a new BelongsTo relationship.
newBelongsToMany()  : BelongsToMany
Instantiate a new BelongsToMany relationship.
newHasMany()  : HasMany
Instantiate a new HasMany relationship.
newHasManyThrough()  : HasManyThrough
Instantiate a new HasManyThrough relationship.
newHasOne()  : HasOne
Instantiate a new HasOne relationship.
newMorphMany()  : MorphMany
Instantiate a new MorphMany relationship.
newMorphOne()  : MorphOne
Instantiate a new MorphOne relationship.
newMorphTo()  : MorphTo
Instantiate a new MorphTo relationship.
newMorphToMany()  : MorphToMany
Instantiate a new HasManyThrough relationship.
newRelatedInstance()  : mixed
Create a new model instance for a related model.
originalIsEquivalent()  : bool
Determine if the new and old values for a given key are equivalent.
performDeleteOnModel()  : void
Perform the actual delete query on this model instance.
performDeleteOnRelations()  : void
Locates relations with delete flag and cascades the delete event.
performInsert()  : bool
Perform a model insert operation.
performUpdate()  : bool
Perform a model update operation.
processRuleFieldNames()  : array<string|int, mixed>
Processes field names in a rule array.
processValidationRules()  : mixed
Process rules
processValidationUniqueRule()  : string
Rebuilds the unique validation rule to force for the existing ID
registerModelEvent()  : void
Register a model event with the dispatcher.
removeTableFromKey()  : string
Remove the table name from a given key.
saveInternal()  : bool
Save the model to the database. Is used by {@link save()} and {@link forceSave()}.
serializeDate()  : string
Prepare a date for array / JSON serialization.
setKeysForSaveQuery()  : Builder
Set the keys for a save update query.
setRelationValue()  : mixed
Sets a relation value directly from its attribute.
updateTimestamps()  : void
Update the creation and update timestamps.
validateRelationArgs()  : mixed
Validate relation supplied arguments.

Constants

CREATED_AT

The name of the "created at" column.

public string CREATED_AT = 'created_at'

UPDATED_AT

The name of the "updated at" column.

public string UPDATED_AT = 'updated_at'

Properties

$attachMany

protected $attachMany = [ 'pictures' => ['October\Rain\Database\Attach\File', 'name'=> 'imageable'] ];

public mixed $attachMany = []

$attachOne

protected $attachOne = [ 'picture' => ['October\Rain\Database\Attach\File', 'public' => false] ];

public mixed $attachOne = []

$belongsTo

protected $belongsTo = [ 'parent' => ['Category', 'key' => 'parent_id'] ];

public mixed $belongsTo = []

$belongsToMany

protected $belongsToMany = [ 'groups' => ['Group', 'table'=> 'join_groups_users'] ];

public mixed $belongsToMany = []

$duplicateCache

public bool $duplicateCache = true

Indicates if duplicate queries from this model should be cached in memory.

$exists

Indicates if the model exists.

public bool $exists = false

$hasMany

public array<string|int, mixed> $hasMany = ['users' => OctoberRainAuthModelsUser::class]

Relations

$hasManyThrough

protected $attachMany = [ 'pictures' => ['Picture', 'name'=> 'imageable'] ];

public mixed $hasManyThrough = []

$hasOne

protected $hasOne = [ 'owner' => ['User', 'key' => 'user_id'] ];

public mixed $hasOne = []

$implement

public array<string|int, mixed> $implement

Behaviors implemented by this model.

$incrementing

Indicates if the IDs are auto-incrementing.

public bool $incrementing = true

$manyMethods

The many to many relationship methods.

public static array<string|int, mixed> $manyMethods = ['belongsToMany', 'morphToMany', 'morphedByMany', 'guessBelongsToManyRelation', 'findFirstMethodThatIsntRelation']

$morphMany

protected $morphMany = [ 'log' => ['History', 'name' => 'user'] ];

public mixed $morphMany = []

$morphOne

protected $morphOne = [ 'log' => ['History', 'name' => 'user'] ];

public mixed $morphOne = []

$morphTo

protected $morphTo = [ 'pictures' => [] ];

public mixed $morphTo = []

$morphToMany

protected $morphToMany = [ 'tag' => ['Tag', 'table' => 'tagables', 'name' => 'tagable'] ];

public mixed $morphToMany = []

$rules

public array<string|int, mixed> $rules = ['name' => 'required|between:4,16|unique:role']

Validation rules

$sessionKey

public string $sessionKey

A unique session key used for deferred binding.

$snakeAttributes

Indicates whether attributes are snake cased on arrays.

public static bool $snakeAttributes = true

$timestamps

Indicates if the model should be timestamped.

public bool $timestamps = true

$wasRecentlyCreated

Indicates if the model was inserted during the current request lifecycle.

public bool $wasRecentlyCreated = false

$allowedPermissionsValues

protected array<string|int, mixed> $allowedPermissionsValues = [0, 1]

Allowed permissions values.

Possible options: 0 => Remove. 1 => Add.

$appends

The accessors to append to the model's array form.

protected array<string|int, mixed> $appends = []

$attributes

The model's attributes.

protected array<string|int, mixed> $attributes = []

$booted

The array of booted models.

protected static array<string|int, mixed> $booted = []

$casts

The attributes that should be cast to native types.

protected array<string|int, mixed> $casts = []

$changes

The changed model attributes.

protected array<string|int, mixed> $changes = []

$connection

The connection name for the model.

protected string $connection

$dateFormat

The storage format of the model's date columns.

protected string $dateFormat

$dates

The attributes that should be mutated to dates.

protected array<string|int, mixed> $dates = []

$dispatcher

The event dispatcher instance.

protected static Dispatcher $dispatcher

$dispatchesEvents

The event map for the model.

protected array<string|int, mixed> $dispatchesEvents = []

Allows for object-based events for native Eloquent events.

$emitterEventCollection

protected array<string|int, mixed> $emitterEventCollection = []

Collection of registered events.

$emitterEventSorted

protected array<string|int, mixed> $emitterEventSorted = []

Sorted collection of events.

$emitterSingleEventCollection

protected array<string|int, mixed> $emitterSingleEventCollection = []

Collection of registered events to be fired once only.

$eventsBooted

protected static array<string|int, mixed> $eventsBooted = []

The array of models booted events.

$extendableCallbacks

protected static array<string|int, mixed> $extendableCallbacks = []

Used to extend the constructor of an extendable class. Eg:

Class::extend(function($obj) { })

$extendableGuardProperties

protected static bool $extendableGuardProperties = true

Indicates if dynamic properties can be created.

$extendableStaticMethods

protected static array<string|int, mixed> $extendableStaticMethods = []

Collection of static methods used by behaviors.

$extensionData

protected array<string|int, mixed> $extensionData = ['extensions' => [], 'methods' => [], 'dynamicMethods' => [], 'dynamicProperties' => []]

Class reflection information, including behaviors.

$fillable

The attributes that are mass assignable.

protected array<string|int, mixed> $fillable = []

$globalScopes

The array of global scopes on the model.

protected static array<string|int, mixed> $globalScopes = []

$guardableColumns

The actual columns that exist on the database and can be guarded.

protected static array<string|int, mixed> $guardableColumns = []

$guarded

protected array<string|int, mixed> $guarded = []

The attributes that aren't mass assignable.

$hidden

The attributes that should be hidden for serialization.

protected array<string|int, mixed> $hidden = []

$jsonable

protected array<string|int, mixed> $jsonable = ['permissions']

List of attribute names which are json encoded and decoded from the database.

$keyType

The "type" of the auto-incrementing ID.

protected string $keyType = 'int'

$mutatorCache

The cache of the mutated attributes for each class.

protected static array<string|int, mixed> $mutatorCache = []

$observables

User exposed observable events.

protected array<string|int, mixed> $observables = []

These are extra user-defined events observers may subscribe to.

$original

The model attribute's original state.

protected array<string|int, mixed> $original = []

$perPage

The number of models to return for pagination.

protected int $perPage = 15

$primaryKey

The primary key for the model.

protected string $primaryKey = 'id'

$relations

The loaded relationships for the model.

protected array<string|int, mixed> $relations = []

$relationTypes

protected static array<string|int, mixed> $relationTypes = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphTo', 'morphOne', 'morphMany', 'morphToMany', 'morphedByMany', 'attachOne', 'attachMany', 'hasManyThrough']

Excepted relationship types, used to cycle and verify relationships.

$table

protected string $table = 'roles'

The table associated with the model.

$touches

The relationships that should be touched on save.

protected array<string|int, mixed> $touches = []

$unguarded

Indicates if all mass assignment is enabled.

protected static bool $unguarded = false

$validationDefaultAttrNames

protected array<string|int, mixed> $validationDefaultAttrNames = []

Default custom attribute names.

$validationErrors

protected MessageBag $validationErrors

The message bag instance containing validation error messages

$visible

The attributes that should be visible in serialization.

protected array<string|int, mixed> $visible = []

$with

The relations to eager load on every query.

protected array<string|int, mixed> $with = []

$withCount

The relationship counts that should be eager loaded on every query.

protected array<string|int, mixed> $withCount = []

Methods

__call()

Handle dynamic method calls into the model.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Return values
mixed —

__callStatic()

Handle dynamic static method calls into the method.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Return values
mixed —

__construct()

Create a new Eloquent model instance.

public __construct([array<string|int, mixed> $attributes = [] ]) : void
Parameters
$attributes : array<string|int, mixed> = []
Return values
void —

__get()

Dynamically retrieve attributes on the model.

public __get(string $key) : mixed
Parameters
$key : string
Return values
mixed —

__isset()

Determine if an attribute or relation exists on the model.

public __isset(string $key) : bool
Parameters
$key : string
Return values
bool —

__set()

Dynamically set attributes on the model.

public __set(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
Return values
void —

__toString()

Convert the model to its string representation.

public __toString() : string
Return values
string —

__unset()

Unset an attribute on the model.

public __unset(string $key) : void
Parameters
$key : string
Return values
void —

__wakeup()

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

public __wakeup() : void
Return values
void —

addCasts()

Add attribute casts for the model.

public addCasts(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>
Return values
void —

addDateAttribute()

Adds a datetime attribute to convert to an instance of Carbon/DateTime object.

public addDateAttribute(string $attribute) : void
Parameters
$attribute : string
Return values
void —

addDynamicMethod()

Programmatically adds a method to the extendable class

public addDynamicMethod(string $dynamicName, callable $method[, string $extension = null ]) : mixed
Parameters
$dynamicName : string
$method : callable
$extension : string = null
Return values
mixed —

addDynamicProperty()

Programmatically adds a property to the extendable class

public addDynamicProperty(string $dynamicName[, string $value = null ]) : mixed
Parameters
$dynamicName : string
$value : string = null
Return values
mixed —

addFillable()

Add fillable attributes for the model.

public addFillable([array<string|int, mixed>|string|null $attributes = null ]) : void
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
void —

addGlobalScope()

Register a new global scope on the model.

public static addGlobalScope(Scope|Closure|string $scope[, Closure|null $implementation = null ]) : mixed
Parameters
$scope : Scope|Closure|string
$implementation : Closure|null = null
Tags
throws
InvalidArgumentException
Return values
mixed —

addHidden()

Add hidden attributes for the model.

public addHidden([array<string|int, mixed>|string|null $attributes = null ]) : void
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
void —

addJsonable()

Add jsonable attributes for the model.

public addJsonable([array<string|int, mixed>|string|null $attributes = null ]) : void
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
void —

addObservableEvents()

Add an observable event name.

public addObservableEvents(array<string|int, mixed>|mixed $observables) : void
Parameters
$observables : array<string|int, mixed>|mixed
Return values
void —

addVisible()

Add visible attributes for the model.

public addVisible([array<string|int, mixed>|string|null $attributes = null ]) : void
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
void —

all()

Get all of the models from the database.

public static all([array<string|int, mixed>|mixed $columns = ['*'] ]) : Collection|array<string|int, static>
Parameters
$columns : array<string|int, mixed>|mixed = ['*']
Return values
Collection|array<string|int, static> —

alwaysPush()

Pushes the first level of relations even if the parent model has no changes.

public alwaysPush(array<string|int, mixed> $options, string $sessionKey) : bool
Parameters
$options : array<string|int, mixed>
$sessionKey : string
Return values
bool —

append()

Append attributes to query when building a query.

public append(array<string|int, mixed>|string $attributes) : $this
Parameters
$attributes : array<string|int, mixed>|string
Return values
$this —

asExtension()

Short hand for `getClassExtension()` method, except takes the short extension name, example:

public asExtension(string $shortName) : mixed

$this->asExtension('FormController')

Parameters
$shortName : string
Return values
mixed —

attachMany()

Define an attachment one-to-many relationship.

public attachMany(mixed $related[, mixed $isPublic = null ][, mixed $localKey = null ][, mixed $relationName = null ]) : MorphMany

This code is a duplicate of Eloquent but uses a Rain relation class.

Parameters
$related : mixed
$isPublic : mixed = null
$localKey : mixed = null
$relationName : mixed = null
Return values
MorphMany —

attachOne()

Define an attachment one-to-one relationship.

public attachOne(mixed $related[, mixed $isPublic = true ][, mixed $localKey = null ][, mixed $relationName = null ]) : MorphOne

This code is a duplicate of Eloquent but uses a Rain relation class.

Parameters
$related : mixed
$isPublic : mixed = true
$localKey : mixed = null
$relationName : mixed = null
Return values
MorphOne —

attributesToArray()

Convert the model's attributes to an array.

public attributesToArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —

belongsTo()

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

public belongsTo(string $related[, string $foreignKey = null ][, string $ownerKey = null ][, string $relation = null ]) : BelongsTo
Parameters
$related : string
$foreignKey : string = null
$ownerKey : string = null
$relation : string = null
Return values
BelongsTo —

belongsToMany()

Define a many-to-many relationship.

public belongsToMany(string $related[, string $table = null ][, string $foreignPivotKey = null ][, string $relatedPivotKey = null ][, string $parentKey = null ][, string $relatedKey = null ][, string $relation = null ]) : BelongsToMany
Parameters
$related : string
$table : string = null
$foreignPivotKey : string = null
$relatedPivotKey : string = null
$parentKey : string = null
$relatedKey : string = null
$relation : string = null
Return values
BelongsToMany —

bindDeferred()

Bind a deferred relationship to the supplied record.

public bindDeferred(mixed $relation, mixed $record, mixed $sessionKey) : mixed
Parameters
$relation : mixed
$record : mixed
$sessionKey : mixed
Return values
mixed —

bindEvent()

Create a new event binding.

public bindEvent(mixed $event, mixed $callback, mixed $priority) : self
Parameters
$event : mixed
$callback : mixed
$priority : mixed
Return values
self —

bindEventOnce()

Create a new event binding that fires once only

public bindEventOnce(mixed $event, mixed $callback) : self
Parameters
$event : mixed
$callback : mixed
Return values
self —

bootValidation()

Boot the validation trait for this model.

public static bootValidation() : void
Return values
void —

cacheMutatedAttributes()

Extract and cache all the mutated attributes of a class.

public static cacheMutatedAttributes(string $class) : void
Parameters
$class : string
Return values
void —

cancelDeferred()

Cancel all deferred bindings to this model.

public cancelDeferred(mixed $sessionKey) : mixed
Parameters
$sessionKey : mixed
Return values
mixed —

clearBootedModels()

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

public static clearBootedModels() : void
Return values
void —

clearExtendedClasses()

Clear the list of extended classes so they will be re-extended.

public static clearExtendedClasses() : void
Return values
void —

commitDeferred()

Commit all deferred bindings to this model.

public commitDeferred(mixed $sessionKey) : mixed
Parameters
$sessionKey : mixed
Return values
mixed —

create()

Save a new model and return the instance.

public static create([array<string|int, mixed> $attributes = [] ][, string $sessionKey = null ]) : Model|static
Parameters
$attributes : array<string|int, mixed> = []
$sessionKey : string = null
Return values
Model|static —

created()

Register a created model event with the dispatcher.

public static created(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

creating()

Register a creating model event with the dispatcher.

public static creating(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

delete()

Delete the model from the database.

public delete() : bool|null
Tags
throws
Exception
Return values
bool|null —

deleted()

Register a deleted model event with the dispatcher.

public static deleted(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

deleting()

Register a deleting model event with the dispatcher.

public static deleting(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

destroy()

Destroy the models for the given IDs.

public static destroy(array<string|int, mixed>|int $ids) : int
Parameters
$ids : array<string|int, mixed>|int
Return values
int —

extend()

Extend this object properties upon construction.

public static extend(Closure $callback) : mixed
Parameters
$callback : Closure
Return values
mixed —

extendableCall()

Magic method for `__call()`

public extendableCall(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
$name : string
$params : array<string|int, mixed> = null
Return values
mixed —

extendableCallStatic()

Magic method for `__callStatic()`

public static extendableCallStatic(string $name[, array<string|int, mixed> $params = null ]) : mixed
Parameters
$name : string
$params : array<string|int, mixed> = null
Return values
mixed —

extendableConstruct()

This method should be called as part of the constructor.

public extendableConstruct() : mixed
Return values
mixed —

extendableExtendCallback()

Helper method for `::extend()` static method

public static extendableExtendCallback(callable $callback) : void
Parameters
$callback : callable
Return values
void —

extendableGet()

Magic method for `__get()`

public extendableGet(string $name) : string
Parameters
$name : string
Return values
string —

extendableSet()

Magic method for `__set()`

public extendableSet(string $name, string $value) : string
Parameters
$name : string
$value : string
Return values
string —

extendClassWith()

Dynamically extend a class with a specified behavior

public extendClassWith(string $extensionName) : void
Parameters
$extensionName : string
Return values
void —

fetched()

Create a new native event for handling afterFetch().

public static fetched(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

fetching()

Create a new native event for handling beforeFetch().

public static fetching(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

fill()

Fill the model with an array of attributes.

public fill(array<string|int, mixed> $attributes) : $this
Parameters
$attributes : array<string|int, mixed>
Tags
throws
MassAssignmentException
Return values
$this —

fillable()

Set the fillable attributes for the model.

public fillable(array<string|int, mixed> $fillable) : $this
Parameters
$fillable : array<string|int, mixed>
Return values
$this —

fillJsonAttribute()

Set a given JSON attribute on the model.

public fillJsonAttribute(string $key, mixed $value) : $this
Parameters
$key : string
$value : mixed
Return values
$this —

fireEvent()

Fire an event and call the listeners.

public fireEvent(string $event[, array<string|int, mixed> $params = [] ][, bool $halt = false ]) : array<string|int, mixed>
Parameters
$event : string

Event name

$params : array<string|int, mixed> = []

Event parameters

$halt : bool = false

Halt after first non-null result

Return values
array<string|int, mixed> —

Collection of event results / Or single result (if halted)

flushDuplicateCache()

Flush the memory cache.

public static flushDuplicateCache() : void
Return values
void —

flushEventListeners()

Remove all of the event listeners for the model.

public static flushEventListeners() : void
Return values
void —

forceDelete()

Force a hard delete on a soft deleted model.

public forceDelete() : bool|null

This method protects developers from running forceDelete when trait is missing.

Return values
bool|null —

forceFill()

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

public forceFill(array<string|int, mixed> $attributes) : $this
Parameters
$attributes : array<string|int, mixed>
Return values
$this —

forceSave()

Force save the model even if validation fails.

public forceSave([mixed $options = null ][, mixed $sessionKey = null ]) : bool
Parameters
$options : mixed = null
$sessionKey : mixed = null
Return values
bool —

fresh()

Reload a fresh model instance from the database.

public fresh([array<string|int, mixed>|string $with = [] ]) : static|null
Parameters
$with : array<string|int, mixed>|string = []
Return values
static|null —

freshTimestampString()

Get a fresh timestamp for the model.

public freshTimestampString() : string
Return values
string —

fromDateTime()

Convert a DateTime to a storable string.

public fromDateTime(DateTime|int $value) : string
Parameters
$value : DateTime|int
Return values
string —

fromJson()

Decode the given JSON back into an array or object.

public fromJson(string $value[, bool $asObject = false ]) : mixed
Parameters
$value : string
$asObject : bool = false
Return values
mixed —

getActualClassNameForMorph()

Retrieve the actual class name for a given morph class.

public static getActualClassNameForMorph(string $class) : string
Parameters
$class : string
Return values
string —

getAttribute()

Get an attribute from the model.

public getAttribute(string $key) : mixed
Parameters
$key : string
Return values
mixed —

getAttributes()

Get all of the current attributes on the model.

public getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getAttributeValue()

Get a plain attribute (not a relationship).

public getAttributeValue(string $key) : mixed
Parameters
$key : string
Return values
mixed —

getCasts()

Get the casts array.

public getCasts() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getChanges()

Get the attributes that were changed.

public getChanges() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getClassExtension()

Returns a behavior object from an extendable class, example:

public getClassExtension(string $name) : mixed

$this->getClassExtension('Backend.Behaviors.FormController')

Parameters
$name : string

Fully qualified behavior name

Return values
mixed —

getClassMethods()

Get a list of class methods, extension equivalent of get_class_methods()

public getClassMethods() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getConnectionName()

Get the current connection name for the model.

public getConnectionName() : string
Return values
string —

getCreatedAtColumn()

Get the name of the "created at" column.

public getCreatedAtColumn() : string
Return values
string —

getDates()

Get the attributes that should be converted to dates.

public getDates() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getDirty()

Get the attributes that have been changed since last sync.

public getDirty() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getDynamicProperties()

Returns all dynamic properties and their values

public getDynamicProperties() : array<string|int, mixed>
Return values
array<string|int, mixed> —

['property' => 'value']

getFillable()

Get the fillable attributes for the model.

public getFillable() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getForeignKey()

Get the default foreign key name for the model.

public getForeignKey() : string
Return values
string —

getGlobalScope()

Get a global scope registered with the model.

public static getGlobalScope(Scope|string $scope) : Scope|Closure|null
Parameters
$scope : Scope|string
Return values
Scope|Closure|null —

getGlobalScopes()

Get the global scopes for this class instance.

public getGlobalScopes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getGuarded()

Get the guarded attributes for the model.

public getGuarded() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getHidden()

Get the hidden attributes for the model.

public getHidden() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getIncrementing()

Get the value indicating whether the IDs are incrementing.

public getIncrementing() : bool
Return values
bool —

getJsonable()

Get the jsonable attributes name

public getJsonable() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getKey()

Get the value of the model's primary key.

public getKey() : mixed
Return values
mixed —

getKeyName()

Get the primary key for the model.

public getKeyName() : string
Return values
string —

getKeyType()

Get the auto-incrementing key type.

public getKeyType() : string
Return values
string —

getMorphClass()

Get the class name for polymorphic relations.

public getMorphClass() : string
Return values
string —

getMutatedAttributes()

Get the mutated attributes for a given instance.

public getMutatedAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getObservableEvents()

Get the observable event names.

public getObservableEvents() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getOriginal()

Get the model's original attribute values.

public getOriginal([string|null $key = null ][, mixed $default = null ]) : mixed|array<string|int, mixed>
Parameters
$key : string|null = null
$default : mixed = null
Return values
mixed|array<string|int, mixed> —

getPerPage()

Get the number of models to return per page.

public getPerPage() : int
Return values
int —

getQualifiedKeyName()

Get the table qualified key name.

public getQualifiedKeyName() : string
Return values
string —

getQueueableConnection()

Get the queueable connection for the entity.

public getQueueableConnection() : mixed
Return values
mixed —

getQueueableId()

Get the queueable identity for the entity.

public getQueueableId() : mixed
Return values
mixed —

getRelation()

Get a specified relationship.

public getRelation(string $relation) : mixed
Parameters
$relation : string
Return values
mixed —

getRelationDefinition()

Returns relationship details from a supplied name.

public getRelationDefinition(string $name) : array<string|int, mixed>
Parameters
$name : string

Relation name

Return values
array<string|int, mixed> —

getRelationDefinitions()

Returns relationship details for all relations defined on this model.

public getRelationDefinitions() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getRelations()

Get all the loaded relations for the instance.

public getRelations() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getRelationType()

Returns a relationship type based on a supplied name.

public getRelationType(string $name) : string
Parameters
$name : string

Relation name

Return values
string —

getRelationValue()

Get a relationship.

public getRelationValue(string $key) : mixed
Parameters
$key : string
Return values
mixed —

getRouteKey()

Get the value of the model's route key.

public getRouteKey() : mixed
Return values
mixed —

getRouteKeyName()

Get the route key for the model.

public getRouteKeyName() : string
Return values
string —

getTable()

Get the table associated with the model.

public getTable() : string
Return values
string —

getTouchedRelations()

Get the relationships that are touched on save.

public getTouchedRelations() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getUpdatedAtColumn()

Get the name of the "updated at" column.

public getUpdatedAtColumn() : string
Return values
string —

getVisible()

Get the visible attributes for the model.

public getVisible() : array<string|int, mixed>
Return values
array<string|int, mixed> —

guard()

Set the guarded attributes for the model.

public guard(array<string|int, mixed> $guarded) : $this
Parameters
$guarded : array<string|int, mixed>
Return values
$this —

hasAccess()

See if a role has access to the passed permission(s).

public hasAccess(string|array<string|int, mixed> $permissions[, bool $all = true ]) : bool

If multiple permissions are passed, the role must have access to all permissions passed through, unless the "all" flag is set to false.

Parameters
$permissions : string|array<string|int, mixed>
$all : bool = true
Return values
bool —

hasAnyAccess()

Returns if the user has access to any of the given permissions.

public hasAnyAccess(array<string|int, mixed> $permissions) : bool
Parameters
$permissions : array<string|int, mixed>
Return values
bool —

hasCast()

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

public hasCast(string $key[, array<string|int, mixed>|string|null $types = null ]) : bool
Parameters
$key : string
$types : array<string|int, mixed>|string|null = null
Return values
bool —

hasGetMutator()

Determine if a get mutator exists for an attribute.

public hasGetMutator(string $key) : bool
Parameters
$key : string
Return values
bool —

hasGlobalScope()

Determine if a model has a global scope.

public static hasGlobalScope(Scope|string $scope) : bool
Parameters
$scope : Scope|string
Return values
bool —

hasMany()

Define a one-to-many relationship.

public hasMany(string $related[, string $foreignKey = null ][, string $localKey = null ]) : HasMany
Parameters
$related : string
$foreignKey : string = null
$localKey : string = null
Return values
HasMany —

hasManyThrough()

Define a has-many-through relationship.

public hasManyThrough(string $related, string $through[, string|null $firstKey = null ][, string|null $secondKey = null ][, string|null $localKey = null ][, string|null $secondLocalKey = null ]) : HasManyThrough
Parameters
$related : string
$through : string
$firstKey : string|null = null
$secondKey : string|null = null
$localKey : string|null = null
$secondLocalKey : string|null = null
Return values
HasManyThrough —

hasOne()

Define a one-to-one relationship.

public hasOne(string $related[, string $foreignKey = null ][, string $localKey = null ]) : HasOne
Parameters
$related : string
$foreignKey : string = null
$localKey : string = null
Return values
HasOne —

hasRelation()

Checks if model has a relationship by supplied name.

public hasRelation(string $name) : bool
Parameters
$name : string

Relation name

Return values
bool —

hasSetMutator()

Determine if a set mutator exists for an attribute.

public hasSetMutator(string $key) : bool
Parameters
$key : string
Return values
bool —

is()

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

public is(Model|null $model) : bool
Parameters
$model : Model|null
Return values
bool —

isAttributeRequired()

Determines if an attribute is required based on the validation rules.

public isAttributeRequired(string $attribute[, bool $checkDependencies = true ]) : bool
Parameters
$attribute : string
$checkDependencies : bool = true

Checks the attribute dependencies (for required_if & required_with rules). Note that it will only be checked up to the next level, if another dependent rule is found then it will just assume the field is required

Return values
bool —

isClassExtendedWith()

Check if extendable class is extended with a behavior object

public isClassExtendedWith(string $name) : bool
Parameters
$name : string

Fully qualified behavior name

Return values
bool —

isClean()

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

public isClean([array<string|int, mixed>|string|null $attributes = null ]) : bool
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
bool —

isDeferrable()

Returns true if a relation exists and can be deferred.

public isDeferrable(mixed $relationName) : mixed
Parameters
$relationName : mixed
Return values
mixed —

isDirty()

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

public isDirty([array<string|int, mixed>|string|null $attributes = null ]) : bool
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
bool —

isFillable()

Determine if the given attribute may be mass assigned.

public isFillable(string $key) : bool
Parameters
$key : string
Return values
bool —

isGuarded()

Determine if the given key is guarded.

public isGuarded(string $key) : bool
Parameters
$key : string
Return values
bool —

isJsonable()

Checks if an attribute is jsonable or not.

public isJsonable(mixed $key) : array<string|int, mixed>
Parameters
$key : mixed
Return values
array<string|int, mixed> —

isNot()

Determine if two models are not the same.

public isNot(Model|null $model) : bool
Parameters
$model : Model|null
Return values
bool —

isRelationPushable()

Determines whether the specified relation should be saved when push() is called instead of save() on the model. Default: true.

public isRelationPushable(string $name) : bool
Parameters
$name : string

Relation name

Return values
bool —

isUnguarded()

Determine if current state is "unguarded".

public static isUnguarded() : bool
Return values
bool —

joiningTable()

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

public joiningTable(string $related) : string
Parameters
$related : string
Return values
string —

jsonable()

Set the jsonable attributes for the model.

public jsonable(array<string|int, mixed> $jsonable) : $this
Parameters
$jsonable : array<string|int, mixed>
Return values
$this —

jsonSerialize()

Convert the object into something JSON serializable.

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —

load()

Eager load relations on the model.

public load(array<string|int, mixed>|string $relations) : $this
Parameters
$relations : array<string|int, mixed>|string
Return values
$this —

loadMissing()

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

public loadMissing(array<string|int, mixed>|string $relations) : $this
Parameters
$relations : array<string|int, mixed>|string
Return values
$this —

make()

Create a new model and return the instance.

public static make([array<string|int, mixed> $attributes = [] ]) : Model|static
Parameters
$attributes : array<string|int, mixed> = []
Return values
Model|static —

makeHidden()

Make the given, typically visible, attributes hidden.

public makeHidden(array<string|int, mixed>|string $attributes) : $this
Parameters
$attributes : array<string|int, mixed>|string
Return values
$this —

makeRelation()

Returns a relation class object

public makeRelation(string $name) : string
Parameters
$name : string

Relation name

Return values
string —

makeVisible()

Make the given, typically hidden, attributes visible.

public makeVisible(array<string|int, mixed>|string $attributes) : $this
Parameters
$attributes : array<string|int, mixed>|string
Return values
$this —

methodExists()

Checks if a method exists, extension equivalent of method_exists()

public methodExists(string $name) : bool
Parameters
$name : string
Return values
bool —

morphedByMany()

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

public morphedByMany(string $related, string $name[, string $table = null ][, string $foreignPivotKey = null ][, string $relatedPivotKey = null ][, string $parentKey = null ][, string $relatedKey = null ]) : MorphToMany
Parameters
$related : string
$name : string
$table : string = null
$foreignPivotKey : string = null
$relatedPivotKey : string = null
$parentKey : string = null
$relatedKey : string = null
Return values
MorphToMany —

morphMany()

Define a polymorphic one-to-many relationship.

public morphMany(string $related, string $name[, string $type = null ][, string $id = null ][, string $localKey = null ]) : MorphMany
Parameters
$related : string
$name : string
$type : string = null
$id : string = null
$localKey : string = null
Return values
MorphMany —

morphOne()

Define a polymorphic one-to-one relationship.

public morphOne(string $related, string $name[, string $type = null ][, string $id = null ][, string $localKey = null ]) : MorphOne
Parameters
$related : string
$name : string
$type : string = null
$id : string = null
$localKey : string = null
Return values
MorphOne —

morphTo()

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

public morphTo([string $name = null ][, string $type = null ][, string $id = null ]) : MorphTo
Parameters
$name : string = null
$type : string = null
$id : string = null
Return values
MorphTo —

morphToMany()

Define a polymorphic many-to-many relationship.

public morphToMany(string $related, string $name[, string $table = null ][, string $foreignPivotKey = null ][, string $relatedPivotKey = null ][, string $parentKey = null ][, string $relatedKey = null ][, bool $inverse = false ]) : MorphToMany
Parameters
$related : string
$name : string
$table : string = null
$foreignPivotKey : string = null
$relatedPivotKey : string = null
$parentKey : string = null
$relatedKey : string = null
$inverse : bool = false
Return values
MorphToMany —

newCollection()

Create a new Eloquent Collection instance.

public newCollection([array<string|int, mixed> $models = [] ]) : Collection
Parameters
$models : array<string|int, mixed> = []
Return values
Collection —

newEloquentBuilder()

Create a new Eloquent query builder for the model.

public newEloquentBuilder(Builder $query) : Builder|static
Parameters
$query : Builder
Return values
Builder|static —

newFromBuilder()

Create a new model instance that is existing.

public newFromBuilder([array<string|int, mixed> $attributes = [] ][, string|null $connection = null ]) : static
Parameters
$attributes : array<string|int, mixed> = []
$connection : string|null = null
Return values
static —

newInstance()

Create a new instance of the given model.

public newInstance([array<string|int, mixed> $attributes = [] ][, bool $exists = false ]) : static
Parameters
$attributes : array<string|int, mixed> = []
$exists : bool = false
Return values
static —

newModelQuery()

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

public newModelQuery() : Builder|static
Return values
Builder|static —

newPivot()

Create a new pivot model instance.

public newPivot(Model $parent, array<string|int, mixed> $attributes, string $table, bool $exists[, string|null $using = null ]) : Pivot
Parameters
$parent : Model
$attributes : array<string|int, mixed>
$table : string
$exists : bool
$using : string|null = null
Return values
Pivot —

newQuery()

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

public newQuery() : Builder
Return values
Builder —

newQueryForRestoration()

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

public newQueryForRestoration(array<string|int, mixed>|int $ids) : Builder
Parameters
$ids : array<string|int, mixed>|int
Return values
Builder —

newQueryWithoutRelationships()

Get a new query builder with no relationships loaded.

public newQueryWithoutRelationships() : Builder
Return values
Builder —

newQueryWithoutScope()

Get a new query instance without a given scope.

public newQueryWithoutScope(Scope|string $scope) : Builder
Parameters
$scope : Scope|string
Return values
Builder —

newQueryWithoutScopes()

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

public newQueryWithoutScopes() : Builder|static
Return values
Builder|static —

newRelationPivot()

Create a pivot model instance specific to a relation.

public newRelationPivot(string $relationName, Model $parent, array<string|int, mixed> $attributes, string $table, bool $exists) : Pivot
Parameters
$relationName : string
$parent : Model
$attributes : array<string|int, mixed>
$table : string
$exists : bool
Return values
Pivot —

observe()

Register an observer with the Model.

public static observe(object|string $class) : void
Parameters
$class : object|string
Return values
void —

offsetExists()

Determine if the given attribute exists.

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool —

offsetGet()

Get the value for a given offset.

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed —

offsetSet()

Set the value for a given offset.

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Return values
void —

offsetUnset()

Unset the value for a given offset.

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Return values
void —

on()

Begin querying the model on a given connection.

public static on([string|null $connection = null ]) : Builder
Parameters
$connection : string|null = null
Return values
Builder —

only()

Get a subset of the model's attributes.

public only(array<string|int, mixed>|mixed $attributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>|mixed
Return values
array<string|int, mixed> —

onWriteConnection()

Begin querying the model on the write connection.

public static onWriteConnection() : Builder
Return values
Builder —

propertyExists()

Checks if a property exists, extension equivalent of `property_exists()`

public propertyExists(string $name) : bool
Parameters
$name : string
Return values
bool —

push()

Save the model and all of its relationships.

public push() : bool
Return values
bool —

qualifyColumn()

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

public qualifyColumn(string $column) : string
Parameters
$column : string
Return values
string —

refresh()

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

public refresh() : $this
Return values
$this —

registerGlobalScopes()

Register the global scopes for this builder instance.

public registerGlobalScopes(Builder $builder) : Builder
Parameters
$builder : Builder
Return values
Builder —

reguard()

Enable the mass assignment restrictions.

public static reguard() : void
Return values
void —

relationLoaded()

Determine if the given relation is loaded.

public relationLoaded(string $key) : bool
Parameters
$key : string
Return values
bool —

relationsToArray()

Get the model's relationships in array form.

public relationsToArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —

reload()

Reloads the model attributes from the database.

public reload() : Model|static
Return values
Model|static —

reloadRelations()

Reloads the model relationship cache.

public reloadRelations([string $relationName = null ]) : void
Parameters
$relationName : string = null
Return values
void —

removeObservableEvents()

Remove an observable event name.

public removeObservableEvents(array<string|int, mixed>|mixed $observables) : void
Parameters
$observables : array<string|int, mixed>|mixed
Return values
void —

replicate()

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

public replicate([array<string|int, mixed>|null $except = null ]) : Model
Parameters
$except : array<string|int, mixed>|null = null
Return values
Model —

resolveConnection()

Resolve a connection instance.

public static resolveConnection([string|null $connection = null ]) : Connection
Parameters
$connection : string|null = null
Return values
Connection —

resolveRouteBinding()

Retrieve the model for a bound value.

public resolveRouteBinding(mixed $value) : Model|null
Parameters
$value : mixed
Return values
Model|null —

retrieved()

Register a retrieved model event with the dispatcher.

public static retrieved(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

save()

Save the model to the database.

public save([array<string|int, mixed> $options = [] ]) : bool
Parameters
$options : array<string|int, mixed> = []
Return values
bool —

saved()

Register a saved model event with the dispatcher.

public static saved(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

saveOrFail()

Save the model to the database using transaction.

public saveOrFail([array<string|int, mixed> $options = [] ]) : bool
Parameters
$options : array<string|int, mixed> = []
Tags
throws
Throwable
Return values
bool —

saving()

Register a saving model event with the dispatcher.

public static saving(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

setAppends()

Set the accessors to append to model arrays.

public setAppends(array<string|int, mixed> $appends) : $this
Parameters
$appends : array<string|int, mixed>
Return values
$this —

setAttribute()

Set a given attribute on the model.

public setAttribute(string $key, mixed $value) : $this
Parameters
$key : string
$value : mixed
Return values
$this —

setConnection()

Set the connection associated with the model.

public setConnection(string $name) : $this
Parameters
$name : string
Return values
$this —

setCreatedAt()

Set the value of the "created at" attribute.

public setCreatedAt(mixed $value) : $this
Parameters
$value : mixed
Return values
$this —

setDateFormat()

Set the date format used by the model.

public setDateFormat(string $format) : $this
Parameters
$format : string
Return values
$this —

setEventDispatcher()

Set the event dispatcher instance.

public static setEventDispatcher(Dispatcher $dispatcher) : void
Parameters
$dispatcher : Dispatcher
Return values
void —

setHidden()

Set the hidden attributes for the model.

public setHidden(array<string|int, mixed> $hidden) : $this
Parameters
$hidden : array<string|int, mixed>
Return values
$this —

setIncrementing()

Set whether IDs are incrementing.

public setIncrementing(bool $value) : $this
Parameters
$value : bool
Return values
$this —

setKeyName()

Set the primary key for the model.

public setKeyName(string $key) : $this
Parameters
$key : string
Return values
$this —

setKeyType()

Set the data type for the primary key.

public setKeyType(string $type) : $this
Parameters
$type : string
Return values
$this —

setObservableEvents()

Set the observable event names.

public setObservableEvents(array<string|int, mixed> $observables) : $this
Parameters
$observables : array<string|int, mixed>
Return values
$this —

setPermissionsAttribute()

Validate the permissions when set.

public setPermissionsAttribute(array<string|int, mixed> $permissions) : void
Parameters
$permissions : array<string|int, mixed>
Return values
void —

setPerPage()

Set the number of models to return per page.

public setPerPage(int $perPage) : $this
Parameters
$perPage : int
Return values
$this —

setRawAttributes()

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

public setRawAttributes(array<string|int, mixed> $attributes[, bool $sync = false ]) : $this
Parameters
$attributes : array<string|int, mixed>
$sync : bool = false
Return values
$this —

setRelation()

Set the specific relationship in the model.

public setRelation(string $relation, mixed $value) : $this
Parameters
$relation : string
$value : mixed
Return values
$this —

setRelations()

Set the entire relations array on the model.

public setRelations(array<string|int, mixed> $relations) : $this
Parameters
$relations : array<string|int, mixed>
Return values
$this —

setTable()

Set the table associated with the model.

public setTable(string $table) : $this
Parameters
$table : string
Return values
$this —

setTouchedRelations()

Set the relationships that are touched on save.

public setTouchedRelations(array<string|int, mixed> $touches) : $this
Parameters
$touches : array<string|int, mixed>
Return values
$this —

setUpdatedAt()

Set the value of the "updated at" attribute.

public setUpdatedAt(mixed $value) : $this
Parameters
$value : mixed
Return values
$this —

setValidationAttributeName()

Programatically sets the validation attribute names, will take lower priority to model defined attribute names found in `$attributeNames`.

public setValidationAttributeName(string $attr, string $name) : void
Parameters
$attr : string
$name : string
Return values
void —

setValidationAttributeNames()

Programatically sets multiple validation attribute names.

public setValidationAttributeNames(array<string|int, mixed> $attributeNames) : void
Parameters
$attributeNames : array<string|int, mixed>
Return values
void —

setVisible()

Set the visible attributes for the model.

public setVisible(array<string|int, mixed> $visible) : $this
Parameters
$visible : array<string|int, mixed>
Return values
$this —

syncChanges()

Sync the changed attributes.

public syncChanges() : $this
Return values
$this —

syncOriginal()

Sync the original attributes with the current.

public syncOriginal() : $this
Return values
$this —

syncOriginalAttribute()

Sync a single original attribute with its current value.

public syncOriginalAttribute(string $attribute) : $this
Parameters
$attribute : string
Return values
$this —

toArray()

Convert the model instance to an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —

toJson()

Convert the model instance to JSON.

public toJson(int $options) : string
Parameters
$options : int
Tags
throws
JsonEncodingException
Return values
string —

totallyGuarded()

Determine if the model is totally guarded.

public totallyGuarded() : bool
Return values
bool —

touch()

Update the model's update timestamp.

public touch() : bool
Return values
bool —

touches()

Determine if the model touches a given relation.

public touches(string $relation) : bool
Parameters
$relation : string
Return values
bool —

touchOwners()

Touch the owning relations of the model.

public touchOwners() : void
Return values
void —

unbindDeferred()

Unbind a deferred relationship to the supplied record.

public unbindDeferred(mixed $relation, mixed $record, mixed $sessionKey) : mixed
Parameters
$relation : mixed
$record : mixed
$sessionKey : mixed
Return values
mixed —

unbindEvent()

Destroys an event binding.

public unbindEvent([string $event = null ]) : self
Parameters
$event : string = null

Event to destroy

Return values
self —

unguard()

Disable all mass assignable restrictions.

public static unguard([bool $state = true ]) : void
Parameters
$state : bool = true
Return values
void —

unguarded()

Run the given callable while being unguarded.

public static unguarded(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed —

unsetConnectionResolver()

Unset the connection resolver for models.

public static unsetConnectionResolver() : void
Return values
void —

unsetEventDispatcher()

Unset the event dispatcher for models.

public static unsetEventDispatcher() : void
Return values
void —

update()

Update the model in the database.

public update([array<string|int, mixed> $attributes = [] ][, array<string|int, mixed> $options = [] ]) : bool
Parameters
$attributes : array<string|int, mixed> = []
$options : array<string|int, mixed> = []
Return values
bool —

updated()

Register an updated model event with the dispatcher.

public static updated(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

updating()

Register an updating model event with the dispatcher.

public static updating(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

usesTimestamps()

Determine if the model uses timestamps.

public usesTimestamps() : bool
Return values
bool —

validate()

Validate the model instance

public validate([mixed $rules = null ][, mixed $customMessages = null ][, mixed $attributeNames = null ]) : bool
Parameters
$rules : mixed = null
$customMessages : mixed = null
$attributeNames : mixed = null
Return values
bool —

validated()

Create a new native event for handling afterValidate().

public static validated(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

validating()

Create a new native event for handling beforeValidate().

public static validating(Closure|string $callback) : void
Parameters
$callback : Closure|string
Return values
void —

wasChanged()

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

public wasChanged([array<string|int, mixed>|string|null $attributes = null ]) : bool
Parameters
$attributes : array<string|int, mixed>|string|null = null
Return values
bool —

with()

Begin querying a model with eager loading.

public static with(array<string|int, mixed>|string $relations) : Builder|static
Parameters
$relations : array<string|int, mixed>|string
Return values
Builder|static —

addCastAttributesToArray()

Add the casted attributes to the attributes array.

protected addCastAttributesToArray(array<string|int, mixed> $attributes, array<string|int, mixed> $mutatedAttributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
$mutatedAttributes : array<string|int, mixed>
Return values
array<string|int, mixed> —

addDateAttributesToArray()

Add the date attributes to the attributes array.

protected addDateAttributesToArray(array<string|int, mixed> $attributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
Return values
array<string|int, mixed> —

addMutatedAttributesToArray()

Add the mutated attributes to the attributes array.

protected addMutatedAttributesToArray(array<string|int, mixed> $attributes, array<string|int, mixed> $mutatedAttributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
$mutatedAttributes : array<string|int, mixed>
Return values
array<string|int, mixed> —

afterCreate()

Handle the "created" model event

protected afterCreate() : mixed
Return values
mixed —

afterDelete()

Handle the "deleted" model event

protected afterDelete() : mixed
Return values
mixed —

afterFetch()

Handle the "fetched" model event

protected afterFetch() : mixed
Return values
mixed —

afterSave()

Handle the "saved" model event

protected afterSave() : mixed
Return values
mixed —

afterUpdate()

Handle the "updated" model event

protected afterUpdate() : mixed
Return values
mixed —

asDate()

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

protected asDate(mixed $value) : Carbon
Parameters
$value : mixed
Return values
Carbon —

asDateTime()

Return a timestamp as DateTime object.

protected asDateTime(mixed $value) : Carbon
Parameters
$value : mixed
Return values
Carbon —

asJson()

Encode the given value as JSON.

protected asJson(mixed $value) : string
Parameters
$value : mixed
Return values
string —

asTimestamp()

Return a timestamp as unix timestamp.

protected asTimestamp(mixed $value) : int
Parameters
$value : mixed
Return values
int —

beforeCreate()

Handle the "creating" model event

protected beforeCreate() : mixed
Return values
mixed —

beforeDelete()

Handle the "deleting" model event

protected beforeDelete() : mixed
Return values
mixed —

beforeFetch()

Handle the "fetching" model event

protected beforeFetch() : mixed
Return values
mixed —

beforeSave()

Handle the "saving" model event

protected beforeSave() : mixed
Return values
mixed —

beforeUpdate()

Handle the "updating" model event

protected beforeUpdate() : mixed
Return values
mixed —

boot()

The "booting" method of the model.

protected static boot() : void
Return values
void —

bootIfNotBooted()

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

protected bootIfNotBooted() : void
Return values
void —

bootNicerEvents()

Bind some nicer events to this model, in the format of method overrides.

protected bootNicerEvents() : mixed
Return values
mixed —

bootTraits()

Boot all of the bootable traits on the model.

protected static bootTraits() : void
Return values
void —

castAttribute()

Cast an attribute to a native PHP type.

protected castAttribute(string $key, mixed $value) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed —

castAttributeAsJson()

Cast the given attribute to JSON.

protected castAttributeAsJson(string $key, mixed $value) : string
Parameters
$key : string
$value : mixed
Return values
string —

commitDeferredAfter()

Internally used method to commit all deferred bindings after saving.

protected commitDeferredAfter(mixed $sessionKey) : mixed
Parameters
$sessionKey : mixed
Return values
mixed —

commitDeferredBefore()

Internally used method to commit all deferred bindings before saving.

protected commitDeferredBefore(mixed $sessionKey) : mixed

It is a rare need to have to call this, since it only applies to the "belongs to" relationship which generally does not need deferring.

Parameters
$sessionKey : mixed
Return values
mixed —

commitDeferredOfType()

Internal method for committing deferred relations.

protected commitDeferredOfType(mixed $sessionKey[, mixed $include = null ][, mixed $exclude = null ]) : mixed
Parameters
$sessionKey : mixed
$include : mixed = null
$exclude : mixed = null
Return values
mixed —

decrement()

Decrement a column's value by a given amount.

protected decrement(string $column[, int $amount = 1 ][, array<string|int, mixed> $extra = [] ]) : int
Parameters
$column : string
$amount : int = 1
$extra : array<string|int, mixed> = []
Return values
int —

emitterEventSortEvents()

Sort the listeners for a given event by priority.

protected emitterEventSortEvents(string $eventName) : array<string|int, mixed>
Parameters
$eventName : string
Return values
array<string|int, mixed> —

extendableIsAccessible()

Checks if a property is accessible, property equivalent of `is_callable()`

protected extendableIsAccessible(mixed $class, string $propertyName) : bool
Parameters
$class : mixed
$propertyName : string
Return values
bool —

extensionExtractMethods()

Extracts the available methods from a behavior and adds it to the list of callable methods.

protected extensionExtractMethods(string $extensionName, object $extensionObject) : void
Parameters
$extensionName : string
$extensionObject : object
Return values
void —

fillableFromArray()

Get the fillable attributes of a given array.

protected fillableFromArray(array<string|int, mixed> $attributes) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
Return values
array<string|int, mixed> —

filterModelEventResults()

Filter the model event results.

protected filterModelEventResults(mixed $result) : mixed
Parameters
$result : mixed
Return values
mixed —

finishSave()

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

protected finishSave(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>
Return values
void —

fireCustomModelEvent()

Fire a custom model event for the given event.

protected fireCustomModelEvent(string $event, string $method) : mixed|null
Parameters
$event : string
$method : string
Return values
mixed|null —

fireModelEvent()

Fire the given event for the model.

protected fireModelEvent(string $event[, bool $halt = true ]) : mixed
Parameters
$event : string
$halt : bool = true
Return values
mixed —

getArrayableAppends()

Get all of the appendable values that are arrayable.

protected getArrayableAppends() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getArrayableAttributes()

Get an attribute array of all arrayable attributes.

protected getArrayableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getArrayableItems()

Get an attribute array of all arrayable values.

protected getArrayableItems(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
$values : array<string|int, mixed>
Return values
array<string|int, mixed> —

getArrayableRelations()

Get an attribute array of all arrayable relations.

protected getArrayableRelations() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getArrayAttributeByKey()

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

protected getArrayAttributeByKey(string $key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed> —

getArrayAttributeWithValue()

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

protected getArrayAttributeWithValue(string $path, string $key, mixed $value) : $this
Parameters
$path : string
$key : string
$value : mixed
Return values
$this —

getAttributeFromArray()

Get an attribute from the $attributes array.

protected getAttributeFromArray(string $key) : mixed
Parameters
$key : string
Return values
mixed —

getCastType()

Get the type of cast for a model attribute.

protected getCastType(string $key) : string
Parameters
$key : string
Return values
string —

getDateFormat()

Get the format for database stored dates.

protected getDateFormat() : string
Return values
string —

getDeferrableRelationTypes()

Returns all possible relation types that can be deferred.

protected getDeferrableRelationTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getDeferredBindingRecords()

Returns any outstanding binding records for this model.

protected getDeferredBindingRecords(mixed $sessionKey) : Collection
Parameters
$sessionKey : mixed
Return values
Collection —

getKeyForSaveQuery()

Get the primary key value for a save query.

protected getKeyForSaveQuery() : mixed
Return values
mixed —

getMorphs()

Get the polymorphic relationship columns.

protected getMorphs(string $name, string $type, string $id) : array<string|int, mixed>
Parameters
$name : string
$type : string
$id : string
Return values
array<string|int, mixed> —

getMutatorMethods()

Get all of the attribute mutator methods.

protected static getMutatorMethods(mixed $class) : array<string|int, mixed>
Parameters
$class : mixed
Return values
array<string|int, mixed> —

getRelationCaller()

Finds the calling function name from the stack trace.

protected getRelationCaller() : mixed
Return values
mixed —

getRelationDefaults()

Returns default relation arguments for a given type.

protected getRelationDefaults(string $type) : array<string|int, mixed>
Parameters
$type : string

Relation type

Return values
array<string|int, mixed> —

getRelationshipFromMethod()

Get a relationship value from a method.

protected getRelationshipFromMethod(string $method) : mixed
Parameters
$method : string
Tags
throws
LogicException
Return values
mixed —

getRelationValidationValue()

Attachments validate differently to their simple values.

protected getRelationValidationValue(mixed $relationName) : mixed
Parameters
$relationName : mixed
Return values
mixed —

getValidationAttributes()

Returns the model data used for validation.

protected getValidationAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

guessBelongsToManyRelation()

Get the relationship name of the belongs to many.

protected guessBelongsToManyRelation() : string
Return values
string —

guessBelongsToRelation()

Guess the "belongs to" relationship name.

protected guessBelongsToRelation() : string
Return values
string —

handleRelation()

Looks for the relation and does the correct magic as Eloquent would require inside relation methods. For more information, read the documentation of the mentioned property.

protected handleRelation(string $relationName) : Relation
Parameters
$relationName : string

the relation key, camel-case version

Return values
Relation —

hasChanges()

Determine if the given attributes were changed.

protected hasChanges(array<string|int, mixed> $changes[, array<string|int, mixed>|string|null $attributes = null ]) : bool
Parameters
$changes : array<string|int, mixed>
$attributes : array<string|int, mixed>|string|null = null
Return values
bool —

increment()

Increment a column's value by a given amount.

protected increment(string $column[, int $amount = 1 ][, array<string|int, mixed> $extra = [] ]) : int
Parameters
$column : string
$amount : int = 1
$extra : array<string|int, mixed> = []
Return values
int —

incrementOrDecrement()

Run the increment or decrement method on the model.

protected incrementOrDecrement(string $column, int $amount, array<string|int, mixed> $extra, string $method) : int
Parameters
$column : string
$amount : int
$extra : array<string|int, mixed>
$method : string
Return values
int —

incrementOrDecrementAttributeValue()

Increment the underlying attribute value and sync with original.

protected incrementOrDecrementAttributeValue(string $column, int $amount, array<string|int, mixed> $extra, string $method) : void
Parameters
$column : string
$amount : int
$extra : array<string|int, mixed>
$method : string
Return values
void —

insertAndSetId()

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

protected insertAndSetId(Builder $query, array<string|int, mixed> $attributes) : void
Parameters
$query : Builder
$attributes : array<string|int, mixed>
Return values
void —

isDateAttribute()

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

protected isDateAttribute(string $key) : bool
Parameters
$key : string
Return values
bool —

isDateCastable()

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

protected isDateCastable(string $key) : bool
Parameters
$key : string
Return values
bool —

isGuardableColumn()

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

protected isGuardableColumn(string $key) : bool
Parameters
$key : string
Return values
bool —

isJsonCastable()

Determine whether a value is JSON castable for inbound manipulation.

protected isJsonCastable(string $key) : bool
Parameters
$key : string
Return values
bool —

isStandardDateFormat()

Determine if the given value is a standard date format.

protected isStandardDateFormat(string $value) : bool
Parameters
$value : string
Return values
bool —

makeValidator()

Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel. Optional connection string to make the validator use a different database connection than the default connection.

protected static makeValidator(mixed $data, mixed $rules, mixed $customMessages, mixed $attributeNames[, mixed $connection = null ]) : Validator
Parameters
$data : mixed
$rules : mixed
$customMessages : mixed
$attributeNames : mixed
$connection : mixed = null
Return values
Validator —

morphEagerTo()

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

protected morphEagerTo(string $name, string $type, string $id) : MorphTo
Parameters
$name : string
$type : string
$id : string
Return values
MorphTo —

morphInstanceTo()

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

protected morphInstanceTo(string $target, string $name, string $type, string $id) : MorphTo
Parameters
$target : string
$name : string
$type : string
$id : string
Return values
MorphTo —

mutateAttribute()

Get the value of an attribute using its mutator.

protected mutateAttribute(string $key, mixed $value) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed —

mutateAttributeForArray()

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

protected mutateAttributeForArray(string $key, mixed $value) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed —

newBaseQueryBuilder()

Get a new query builder instance for the connection.

protected newBaseQueryBuilder() : Builder
Return values
Builder —

newBelongsTo()

Instantiate a new BelongsTo relationship.

protected newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation) : BelongsTo
Parameters
$query : Builder
$child : Model
$foreignKey : string
$ownerKey : string
$relation : string
Return values
BelongsTo —

newBelongsToMany()

Instantiate a new BelongsToMany relationship.

protected newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey[, string $relationName = null ]) : BelongsToMany
Parameters
$query : Builder
$parent : Model
$table : string
$foreignPivotKey : string
$relatedPivotKey : string
$parentKey : string
$relatedKey : string
$relationName : string = null
Return values
BelongsToMany —

newHasMany()

Instantiate a new HasMany relationship.

protected newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey) : HasMany
Parameters
$query : Builder
$parent : Model
$foreignKey : string
$localKey : string
Return values
HasMany —

newHasManyThrough()

Instantiate a new HasManyThrough relationship.

protected newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey) : HasManyThrough
Parameters
$query : Builder
$farParent : Model
$throughParent : Model
$firstKey : string
$secondKey : string
$localKey : string
$secondLocalKey : string
Return values
HasManyThrough —

newHasOne()

Instantiate a new HasOne relationship.

protected newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey) : HasOne
Parameters
$query : Builder
$parent : Model
$foreignKey : string
$localKey : string
Return values
HasOne —

newMorphMany()

Instantiate a new MorphMany relationship.

protected newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey) : MorphMany
Parameters
$query : Builder
$parent : Model
$type : string
$id : string
$localKey : string
Return values
MorphMany —

newMorphOne()

Instantiate a new MorphOne relationship.

protected newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey) : MorphOne
Parameters
$query : Builder
$parent : Model
$type : string
$id : string
$localKey : string
Return values
MorphOne —

newMorphTo()

Instantiate a new MorphTo relationship.

protected newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation) : MorphTo
Parameters
$query : Builder
$parent : Model
$foreignKey : string
$ownerKey : string
$type : string
$relation : string
Return values
MorphTo —

newMorphToMany()

Instantiate a new HasManyThrough relationship.

protected newMorphToMany(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey[, string $relationName = null ][, bool $inverse = false ]) : MorphToMany
Parameters
$query : Builder
$parent : Model
$name : string
$table : string
$foreignPivotKey : string
$relatedPivotKey : string
$parentKey : string
$relatedKey : string
$relationName : string = null
$inverse : bool = false
Return values
MorphToMany —

newRelatedInstance()

Create a new model instance for a related model.

protected newRelatedInstance(string $class) : mixed
Parameters
$class : string
Return values
mixed —

originalIsEquivalent()

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

protected originalIsEquivalent(string $key, mixed $current) : bool
Parameters
$key : string
$current : mixed
Return values
bool —

performDeleteOnModel()

Perform the actual delete query on this model instance.

protected performDeleteOnModel() : void
Return values
void —

performDeleteOnRelations()

Locates relations with delete flag and cascades the delete event.

protected performDeleteOnRelations() : void
Return values
void —

performInsert()

Perform a model insert operation.

protected performInsert(Builder $query) : bool
Parameters
$query : Builder
Return values
bool —

performUpdate()

Perform a model update operation.

protected performUpdate(Builder $query) : bool
Parameters
$query : Builder
Return values
bool —

processRuleFieldNames()

Processes field names in a rule array.

protected processRuleFieldNames(array<string|int, mixed> $rules) : array<string|int, mixed>

Converts any field names using array notation (ie. field[child]) into dot notation (ie. field.child)

Parameters
$rules : array<string|int, mixed>

Rules array

Return values
array<string|int, mixed> —

processValidationRules()

Process rules

protected processValidationRules(mixed $rules) : mixed
Parameters
$rules : mixed
Return values
mixed —

processValidationUniqueRule()

Rebuilds the unique validation rule to force for the existing ID

protected processValidationUniqueRule(string $definition, string $fieldName) : string
Parameters
$definition : string
$fieldName : string
Return values
string —

registerModelEvent()

Register a model event with the dispatcher.

protected static registerModelEvent(string $event, Closure|string $callback) : void
Parameters
$event : string
$callback : Closure|string
Return values
void —

removeTableFromKey()

Remove the table name from a given key.

protected removeTableFromKey(string $key) : string
Parameters
$key : string
Return values
string —

saveInternal()

Save the model to the database. Is used by {@link save()} and {@link forceSave()}.

protected saveInternal([array<string|int, mixed> $options = [] ]) : bool
Parameters
$options : array<string|int, mixed> = []
Return values
bool —

serializeDate()

Prepare a date for array / JSON serialization.

protected serializeDate(DateTimeInterface $date) : string
Parameters
$date : DateTimeInterface
Return values
string —

setKeysForSaveQuery()

Set the keys for a save update query.

protected setKeysForSaveQuery(Builder $query) : Builder
Parameters
$query : Builder
Return values
Builder —

setRelationValue()

Sets a relation value directly from its attribute.

protected setRelationValue(mixed $relationName, mixed $value) : mixed
Parameters
$relationName : mixed
$value : mixed
Return values
mixed —

updateTimestamps()

Update the creation and update timestamps.

protected updateTimestamps() : void
Return values
void —

validateRelationArgs()

Validate relation supplied arguments.

protected validateRelationArgs(mixed $relationName, mixed $optional[, mixed $required = [] ]) : mixed
Parameters
$relationName : mixed
$optional : mixed
$required : mixed = []
Return values
mixed —

Search results