class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable (View source)

Constants

CREATED_AT

The name of the "created at" column.

UPDATED_AT

The name of the "updated at" column.

Properties

bool $incrementing Indicates if the IDs are auto-incrementing.
bool $timestamps Indicates if the model should be timestamped.
bool $exists Indicates if the model exists.
static bool $snakeAttributes Indicates whether attributes are snake cased on arrays.
static array $manyMethods The many to many relationship methods.

Methods

void
__construct(array $attributes = array())

Create a new Eloquent model instance.

static void
addGlobalScope(ScopeInterface $scope)

Register a new global scope on the model.

static bool
hasGlobalScope(ScopeInterface $scope)

Determine if a model has a global scope.

static ScopeInterface|null
getGlobalScope(ScopeInterface $scope)

Get a global scope registered with the model.

getGlobalScopes()

Get the global scopes for this class instance.

static void
observe(object|string $class)

Register an observer with the Model.

$this
fill(array $attributes)

Fill the model with an array of attributes.

$this
forceFill(array $attributes)

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

newInstance(array $attributes = array(), bool $exists = false)

Create a new instance of the given model.

newFromBuilder(array $attributes = array(), string|null $connection = null)

Create a new model instance that is existing.

static Collection
hydrate(array $items, string|null $connection = null)

Create a collection of models from plain arrays.

static Collection
hydrateRaw(string $query, array $bindings = array(), string|null $connection = null)

Create a collection of models from a raw query.

static Model
create(array $attributes)

Save a new model and return the instance.

static Model
forceCreate(array $attributes)

Save a new model and return the instance. Allow mass-assignment.

static Model
firstOrCreate(array $attributes)

Get the first record matching the attributes or create it.

static Model
firstOrNew(array $attributes)

Get the first record matching the attributes or instantiate it.

static Model
updateOrCreate(array $attributes, array $values = array())

Create or update a record matching the attributes, and fill it with values.

static Builder
query()

Begin querying the model.

static Builder
on(string|null $connection = null)

Begin querying the model on a given connection.

static Builder
onWriteConnection()

Begin querying the model on the write connection.

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

Get all of the models from the database.

static Collection|Model|null
find(mixed $id, array $columns = array('*'))

Find a model by its primary key.

static Collection|Model
findOrNew(mixed $id, array $columns = array('*'))

Find a model by its primary key or return new static.

$this
fresh(array $with = array())

Reload a fresh model instance from the database.

$this
load(array|string $relations)

Eager load relations on the model.

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

Being querying a model with eager loading.

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

Define a one-to-one relationship.

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

Define a polymorphic one-to-one relationship.

belongsTo(string $related, string $foreignKey = null, string $otherKey = null, string $relation = null)

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

morphTo(string $name = null, string $type = null, string $id = null)

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

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

Define a one-to-many relationship.

hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null)

Define a has-many-through relationship.

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

Define a polymorphic one-to-many relationship.

belongsToMany(string $related, string $table = null, string $foreignKey = null, string $otherKey = null, string $relation = null)

Define a many-to-many relationship.

morphToMany(string $related, string $name, string $table = null, string $foreignKey = null, string $otherKey = null, bool $inverse = false)

Define a polymorphic many-to-many relationship.

morphedByMany(string $related, string $name, string $table = null, string $foreignKey = null, string $otherKey = null)

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

string
joiningTable(string $related)

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

static int
destroy(array|int $ids)

Destroy the models for the given IDs.

bool|null
delete()

Delete the model from the database.

void
forceDelete()

Force a hard delete on a soft deleted model.

static void
saving(Closure|string $callback, int $priority)

Register a saving model event with the dispatcher.

static void
saved(Closure|string $callback, int $priority)

Register a saved model event with the dispatcher.

static void
updating(Closure|string $callback, int $priority)

Register an updating model event with the dispatcher.

static void
updated(Closure|string $callback, int $priority)

Register an updated model event with the dispatcher.

static void
creating(Closure|string $callback, int $priority)

Register a creating model event with the dispatcher.

static void
created(Closure|string $callback, int $priority)

Register a created model event with the dispatcher.

static void
deleting(Closure|string $callback, int $priority)

Register a deleting model event with the dispatcher.

static void
deleted(Closure|string $callback, int $priority)

Register a deleted model event with the dispatcher.

static void
flushEventListeners()

Remove all of the event listeners for the model.

array
getObservableEvents()

Get the observable event names.

void
setObservableEvents(array $observables)

Set the observable event names.

void
addObservableEvents(mixed $observables)

Add an observable event name.

void
removeObservableEvents(mixed $observables)

Remove an observable event name.

bool|int
update(array $attributes = array())

Update the model in the database.

bool
push()

Save the model and all of its relationships.

bool
save(array $options = array())

Save the model to the database.

void
touchOwners()

Touch the owning relations of the model.

bool
touches(string $relation)

Determine if the model touches a given relation.

bool
touch()

Update the model's update timestamp.

void
setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

void
setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

string
getCreatedAtColumn()

Get the name of the "created at" column.

string
getUpdatedAtColumn()

Get the name of the "updated at" column.

Carbon
freshTimestamp()

Get a fresh timestamp for the model.

string
freshTimestampString()

Get a fresh timestamp for the model.

newQuery()

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

newQueryWithoutScope(ScopeInterface $scope)

Get a new query instance without a given scope.

newQueryWithoutScopes()

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

applyGlobalScopes(Builder $builder)

Apply all of the global scopes to an Eloquent builder.

removeGlobalScopes(Builder $builder)

Remove all of the global scopes from an Eloquent builder.

newEloquentBuilder(Builder $query)

Create a new Eloquent query builder for the model.

newCollection(array $models = array())

Create a new Eloquent Collection instance.

newPivot(Model $parent, array $attributes, string $table, bool $exists)

Create a new pivot model instance.

string
getTable()

Get the table associated with the model.

void
setTable(string $table)

Set the table associated with the model.

mixed
getKey()

Get the value of the model's primary key.

mixed
getQueueableId()

Get the queueable identity for the entity.

string
getKeyName()

Get the primary key for the model.

void
setKeyName(string $key)

Set the primary key for the model.

string
getQualifiedKeyName()

Get the table qualified key name.

mixed
getRouteKey()

Get the value of the model's route key.

string
getRouteKeyName()

Get the route key for the model.

bool
usesTimestamps()

Determine if the model uses timestamps.

string
getMorphClass()

Get the class name for polymorphic relations.

int
getPerPage()

Get the number of models to return per page.

void
setPerPage(int $perPage)

Set the number of models to return per page.

string
getForeignKey()

Get the default foreign key name for the model.

array
getHidden()

Get the hidden attributes for the model.

void
setHidden(array $hidden)

Set the hidden attributes for the model.

void
addHidden(array|string|null $attributes = null)

Add hidden attributes for the model.

array
getVisible()

Get the visible attributes for the model.

void
setVisible(array $visible)

Set the visible attributes for the model.

void
addVisible(array|string|null $attributes = null)

Add visible attributes for the model.

void
setAppends(array $appends)

Set the accessors to append to model arrays.

array
getFillable()

Get the fillable attributes for the model.

$this
fillable(array $fillable)

Set the fillable attributes for the model.

array
getGuarded()

Get the guarded attributes for the model.

$this
guard(array $guarded)

Set the guarded attributes for the model.

static void
unguard($state = true)

Disable all mass assignable restrictions.

static void
reguard()

Enable the mass assignment restrictions.

static bool
isUnguarded()

Determine if current state is "unguarded".

static mixed
unguarded(callable $callback)

Run the given callable while being unguarded.

bool
isFillable(string $key)

Determine if the given attribute may be mass assigned.

bool
isGuarded(string $key)

Determine if the given key is guarded.

bool
totallyGuarded()

Determine if the model is totally guarded.

array
getTouchedRelations()

Get the relationships that are touched on save.

void
setTouchedRelations(array $touches)

Set the relationships that are touched on save.

bool
getIncrementing()

Get the value indicating whether the IDs are incrementing.

void
setIncrementing(bool $value)

Set whether IDs are incrementing.

string
toJson(int $options)

Convert the model instance to JSON.

array
jsonSerialize()

Convert the object into something JSON serializable.

array
toArray()

Convert the model instance to an array.

array
attributesToArray()

Convert the model's attributes to an array.

array
relationsToArray()

Get the model's relationships in array form.

mixed
getAttribute(string $key)

Get an attribute from the model.

bool
hasGetMutator(string $key)

Determine if a get mutator exists for an attribute.

void
setAttribute(string $key, mixed $value)

Set a given attribute on the model.

bool
hasSetMutator(string $key)

Determine if a set mutator exists for an attribute.

array
getDates()

Get the attributes that should be converted to dates.

string
fromDateTime(DateTime|int $value)

Convert a DateTime to a storable string.

replicate(array $except = null)

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

array
getAttributes()

Get all of the current attributes on the model.

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

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

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

Get the model's original attribute values.

$this
syncOriginal()

Sync the original attributes with the current.

$this
syncOriginalAttribute(string $attribute)

Sync a single original attribute with its current value.

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

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

array
getDirty()

Get the attributes that have been changed since last sync.

array
getRelations()

Get all the loaded relations for the instance.

mixed
getRelation(string $relation)

Get a specified relationship.

$this
setRelation(string $relation, mixed $value)

Set the specific relationship in the model.

$this
setRelations(array $relations)

Set the entire relations array on the model.

getConnection()

Get the database connection for the model.

string
getConnectionName()

Get the current connection name for the model.

$this
setConnection(string $name)

Set the connection associated with the model.

static Connection
resolveConnection(string $connection = null)

Resolve a connection instance.

getConnectionResolver()

Get the connection resolver instance.

static void
setConnectionResolver(ConnectionResolverInterface $resolver)

Set the connection resolver instance.

static void
unsetConnectionResolver()

Unset the connection resolver for models.

static Dispatcher
getEventDispatcher()

Get the event dispatcher instance.

static void
setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

static void
unsetEventDispatcher()

Unset the event dispatcher for models.

array
getMutatedAttributes()

Get the mutated attributes for a given instance.

static void
cacheMutatedAttributes(string $class)

Extract and cache all the mutated attributes of a class.

mixed
__get(string $key)

Dynamically retrieve attributes on the model.

void
__set(string $key, mixed $value)

Dynamically set attributes on the model.

bool
offsetExists(mixed $offset)

Determine if the given attribute exists.

mixed
offsetGet(mixed $offset)

Get the value for a given offset.

void
offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

void
offsetUnset(mixed $offset)

Unset the value for a given offset.

bool
__isset(string $key)

Determine if an attribute exists on the model.

void
__unset(string $key)

Unset an attribute on the model.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls into the model.

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

Handle dynamic static method calls into the method.

string
__toString()

Convert the model to its string representation.

void
__wakeup()

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

Details

at line line 253
void __construct(array $attributes = array())

Create a new Eloquent model instance.

Parameters

array $attributes

Return Value

void

at line line 315
static void addGlobalScope(ScopeInterface $scope)

Register a new global scope on the model.

Parameters

ScopeInterface $scope

Return Value

void

at line line 326
static bool hasGlobalScope(ScopeInterface $scope)

Determine if a model has a global scope.

Parameters

ScopeInterface $scope

Return Value

bool

at line line 337
static ScopeInterface|null getGlobalScope(ScopeInterface $scope)

Get a global scope registered with the model.

Parameters

ScopeInterface $scope

Return Value

ScopeInterface|null

at line line 350
ScopeInterface[] getGlobalScopes()

Get the global scopes for this class instance.

Return Value

ScopeInterface[]

at line line 361
static void observe(object|string $class)

Register an observer with the Model.

Parameters

object|string $class

Return Value

void

at line line 387
$this fill(array $attributes)

Fill the model with an array of attributes.

Parameters

array $attributes

Return Value

$this

Exceptions

MassAssignmentException

at line line 417
$this forceFill(array $attributes)

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

Parameters

array $attributes

Return Value

$this

at line line 453
Model newInstance(array $attributes = array(), bool $exists = false)

Create a new instance of the given model.

Parameters

array $attributes
bool $exists

Return Value

Model

at line line 472
Model newFromBuilder(array $attributes = array(), string|null $connection = null)

Create a new model instance that is existing.

Parameters

array $attributes
string|null $connection

Return Value

Model

at line line 490
static Collection hydrate(array $items, string|null $connection = null)

Create a collection of models from plain arrays.

Parameters

array $items
string|null $connection

Return Value

Collection

at line line 510
static Collection hydrateRaw(string $query, array $bindings = array(), string|null $connection = null)

Create a collection of models from a raw query.

Parameters

string $query
array $bindings
string|null $connection

Return Value

Collection

at line line 525
static Model create(array $attributes)

Save a new model and return the instance.

Parameters

array $attributes

Return Value

Model

at line line 540
static Model forceCreate(array $attributes)

Save a new model and return the instance. Allow mass-assignment.

Parameters

array $attributes

Return Value

Model

at line line 559
static Model firstOrCreate(array $attributes)

Get the first record matching the attributes or create it.

Parameters

array $attributes

Return Value

Model

at line line 575
static Model firstOrNew(array $attributes)

Get the first record matching the attributes or instantiate it.

Parameters

array $attributes

Return Value

Model

at line line 592
static Model updateOrCreate(array $attributes, array $values = array())

Create or update a record matching the attributes, and fill it with values.

Parameters

array $attributes
array $values

Return Value

Model

at line line 617
static Builder query()

Begin querying the model.

Return Value

Builder

at line line 628
static Builder on(string|null $connection = null)

Begin querying the model on a given connection.

Parameters

string|null $connection

Return Value

Builder

at line line 645
static Builder onWriteConnection()

Begin querying the model on the write connection.

Return Value

Builder

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

Get all of the models from the database.

Parameters

array $columns

Return Value

Collection|Model[]

at line line 672
static Collection|Model|null find(mixed $id, array $columns = array('*'))

Find a model by its primary key.

Parameters

mixed $id
array $columns

Return Value

Collection|Model|null

at line line 684
static Collection|Model findOrNew(mixed $id, array $columns = array('*'))

Find a model by its primary key or return new static.

Parameters

mixed $id
array $columns

Return Value

Collection|Model

at line line 697
$this fresh(array $with = array())

Reload a fresh model instance from the database.

Parameters

array $with

Return Value

$this

at line line 712
$this load(array|string $relations)

Eager load relations on the model.

Parameters

array|string $relations

Return Value

$this

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

Being querying a model with eager loading.

Parameters

array|string $relations

Return Value

Builder|Model

at line line 746
HasOne hasOne(string $related, string $foreignKey = null, string $localKey = null)

Define a one-to-one relationship.

Parameters

string $related
string $foreignKey
string $localKey

Return Value

HasOne

at line line 767
MorphOne morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null)

Define a polymorphic one-to-one relationship.

Parameters

string $related
string $name
string $type
string $id
string $localKey

Return Value

MorphOne

at line line 789
BelongsTo belongsTo(string $related, string $foreignKey = null, string $otherKey = null, string $relation = null)

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

Parameters

string $related
string $foreignKey
string $otherKey
string $relation

Return Value

BelongsTo

at line line 829
MorphTo morphTo(string $name = null, string $type = null, string $id = null)

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

Parameters

string $name
string $type
string $id

Return Value

MorphTo

at line line 874
HasMany hasMany(string $related, string $foreignKey = null, string $localKey = null)

Define a one-to-many relationship.

Parameters

string $related
string $foreignKey
string $localKey

Return Value

HasMany

at line line 894
HasManyThrough hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null)

Define a has-many-through relationship.

Parameters

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

Return Value

HasManyThrough

at line line 915
MorphMany morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null)

Define a polymorphic one-to-many relationship.

Parameters

string $related
string $name
string $type
string $id
string $localKey

Return Value

MorphMany

at line line 941
BelongsToMany belongsToMany(string $related, string $table = null, string $foreignKey = null, string $otherKey = null, string $relation = null)

Define a many-to-many relationship.

Parameters

string $related
string $table
string $foreignKey
string $otherKey
string $relation

Return Value

BelongsToMany

at line line 987
MorphToMany morphToMany(string $related, string $name, string $table = null, string $foreignKey = null, string $otherKey = null, bool $inverse = false)

Define a polymorphic many-to-many relationship.

Parameters

string $related
string $name
string $table
string $foreignKey
string $otherKey
bool $inverse

Return Value

MorphToMany

at line line 1023
MorphToMany morphedByMany(string $related, string $name, string $table = null, string $foreignKey = null, string $otherKey = null)

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

Parameters

string $related
string $name
string $table
string $foreignKey
string $otherKey

Return Value

MorphToMany

at line line 1060
string joiningTable(string $related)

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

Parameters

string $related

Return Value

string

at line line 1085
static int destroy(array|int $ids)

Destroy the models for the given IDs.

Parameters

array|int $ids

Return Value

int

at line line 1115
bool|null delete()

Delete the model from the database.

Return Value

bool|null

Exceptions

Exception

at line line 1151
void forceDelete()

Force a hard delete on a soft deleted model.

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

Return Value

void

at line line 1173
static void saving(Closure|string $callback, int $priority)

Register a saving model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1185
static void saved(Closure|string $callback, int $priority)

Register a saved model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1197
static void updating(Closure|string $callback, int $priority)

Register an updating model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1209
static void updated(Closure|string $callback, int $priority)

Register an updated model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1221
static void creating(Closure|string $callback, int $priority)

Register a creating model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1233
static void created(Closure|string $callback, int $priority)

Register a created model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1245
static void deleting(Closure|string $callback, int $priority)

Register a deleting model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1257
static void deleted(Closure|string $callback, int $priority)

Register a deleted model event with the dispatcher.

Parameters

Closure|string $callback
int $priority

Return Value

void

at line line 1267
static void flushEventListeners()

Remove all of the event listeners for the model.

Return Value

void

at line line 1302
array getObservableEvents()

Get the observable event names.

Return Value

array

at line line 1320
void setObservableEvents(array $observables)

Set the observable event names.

Parameters

array $observables

Return Value

void

at line line 1331
void addObservableEvents(mixed $observables)

Add an observable event name.

Parameters

mixed $observables

Return Value

void

at line line 1344
void removeObservableEvents(mixed $observables)

Remove an observable event name.

Parameters

mixed $observables

Return Value

void

at line line 1418
bool|int update(array $attributes = array())

Update the model in the database.

Parameters

array $attributes

Return Value

bool|int

at line line 1433
bool push()

Save the model and all of its relationships.

Return Value

bool

at line line 1460
bool save(array $options = array())

Save the model to the database.

Parameters

array $options

Return Value

bool

at line line 1619
void touchOwners()

Touch the owning relations of the model.

Return Value

void

at line line 1645
bool touches(string $relation)

Determine if the model touches a given relation.

Parameters

string $relation

Return Value

bool

at line line 1704
bool touch()

Update the model's update timestamp.

Return Value

bool

at line line 1739
void setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

Parameters

mixed $value

Return Value

void

at line line 1750
void setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

Parameters

mixed $value

Return Value

void

at line line 1760
string getCreatedAtColumn()

Get the name of the "created at" column.

Return Value

string

at line line 1770
string getUpdatedAtColumn()

Get the name of the "updated at" column.

Return Value

string

at line line 1780
Carbon freshTimestamp()

Get a fresh timestamp for the model.

Return Value

Carbon

at line line 1790
string freshTimestampString()

Get a fresh timestamp for the model.

Return Value

string

at line line 1800
Builder newQuery()

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

Return Value

Builder

at line line 1813
Builder newQueryWithoutScope(ScopeInterface $scope)

Get a new query instance without a given scope.

Parameters

ScopeInterface $scope

Return Value

Builder

at line line 1825
Builder|Model newQueryWithoutScopes()

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

Return Value

Builder|Model

at line line 1843
Builder applyGlobalScopes(Builder $builder)

Apply all of the global scopes to an Eloquent builder.

Parameters

Builder $builder

Return Value

Builder

at line line 1859
Builder removeGlobalScopes(Builder $builder)

Remove all of the global scopes from an Eloquent builder.

Parameters

Builder $builder

Return Value

Builder

at line line 1875
Builder|Model newEloquentBuilder(Builder $query)

Create a new Eloquent query builder for the model.

Parameters

Builder $query

Return Value

Builder|Model

at line line 1900
Collection newCollection(array $models = array())

Create a new Eloquent Collection instance.

Parameters

array $models

Return Value

Collection

at line line 1914
Pivot newPivot(Model $parent, array $attributes, string $table, bool $exists)

Create a new pivot model instance.

Parameters

Model $parent
array $attributes
string $table
bool $exists

Return Value

Pivot

at line line 1924
string getTable()

Get the table associated with the model.

Return Value

string

at line line 1937
void setTable(string $table)

Set the table associated with the model.

Parameters

string $table

Return Value

void

at line line 1947
mixed getKey()

Get the value of the model's primary key.

Return Value

mixed

at line line 1957
mixed getQueueableId()

Get the queueable identity for the entity.

Return Value

mixed

at line line 1967
string getKeyName()

Get the primary key for the model.

Return Value

string

at line line 1978
void setKeyName(string $key)

Set the primary key for the model.

Parameters

string $key

Return Value

void

at line line 1988
string getQualifiedKeyName()

Get the table qualified key name.

Return Value

string

at line line 1998
mixed getRouteKey()

Get the value of the model's route key.

Return Value

mixed

at line line 2008
string getRouteKeyName()

Get the route key for the model.

Return Value

string

at line line 2018
bool usesTimestamps()

Determine if the model uses timestamps.

Return Value

bool

at line line 2045
string getMorphClass()

Get the class name for polymorphic relations.

Return Value

string

at line line 2055
int getPerPage()

Get the number of models to return per page.

Return Value

int

at line line 2066
void setPerPage(int $perPage)

Set the number of models to return per page.

Parameters

int $perPage

Return Value

void

at line line 2076
string getForeignKey()

Get the default foreign key name for the model.

Return Value

string

at line line 2086
array getHidden()

Get the hidden attributes for the model.

Return Value

array

at line line 2097
void setHidden(array $hidden)

Set the hidden attributes for the model.

Parameters

array $hidden

Return Value

void

at line line 2108
void addHidden(array|string|null $attributes = null)

Add hidden attributes for the model.

Parameters

array|string|null $attributes

Return Value

void

at line line 2120
array getVisible()

Get the visible attributes for the model.

Return Value

array

at line line 2131
void setVisible(array $visible)

Set the visible attributes for the model.

Parameters

array $visible

Return Value

void

at line line 2142
void addVisible(array|string|null $attributes = null)

Add visible attributes for the model.

Parameters

array|string|null $attributes

Return Value

void

at line line 2155
void setAppends(array $appends)

Set the accessors to append to model arrays.

Parameters

array $appends

Return Value

void

at line line 2165
array getFillable()

Get the fillable attributes for the model.

Return Value

array

at line line 2176
$this fillable(array $fillable)

Set the fillable attributes for the model.

Parameters

array $fillable

Return Value

$this

at line line 2188
array getGuarded()

Get the guarded attributes for the model.

Return Value

array

at line line 2199
$this guard(array $guarded)

Set the guarded attributes for the model.

Parameters

array $guarded

Return Value

$this

at line line 2211
static void unguard($state = true)

Disable all mass assignable restrictions.

Parameters

$state

Return Value

void

at line line 2221
static void reguard()

Enable the mass assignment restrictions.

Return Value

void

at line line 2231
static bool isUnguarded()

Determine if current state is "unguarded".

Return Value

bool

at line line 2242
static mixed unguarded(callable $callback)

Run the given callable while being unguarded.

Parameters

callable $callback

Return Value

mixed

at line line 2261
bool isFillable(string $key)

Determine if the given attribute may be mass assigned.

Parameters

string $key

Return Value

bool

at line line 2281
bool isGuarded(string $key)

Determine if the given key is guarded.

Parameters

string $key

Return Value

bool

at line line 2291
bool totallyGuarded()

Determine if the model is totally guarded.

Return Value

bool

at line line 2314
array getTouchedRelations()

Get the relationships that are touched on save.

Return Value

array

at line line 2325
void setTouchedRelations(array $touches)

Set the relationships that are touched on save.

Parameters

array $touches

Return Value

void

at line line 2335
bool getIncrementing()

Get the value indicating whether the IDs are incrementing.

Return Value

bool

at line line 2346
void setIncrementing(bool $value)

Set whether IDs are incrementing.

Parameters

bool $value

Return Value

void

at line line 2357
string toJson(int $options)

Convert the model instance to JSON.

Parameters

int $options

Return Value

string

at line line 2367
array jsonSerialize()

Convert the object into something JSON serializable.

Return Value

array

at line line 2377
array toArray()

Convert the model instance to an array.

Return Value

array

at line line 2389
array attributesToArray()

Convert the model's attributes to an array.

Return Value

array

at line line 2470
array relationsToArray()

Get the model's relationships in array form.

Return Value

array

at line line 2548
mixed getAttribute(string $key)

Get an attribute from the model.

Parameters

string $key

Return Value

mixed

at line line 2655
bool hasGetMutator(string $key)

Determine if a get mutator exists for an attribute.

Parameters

string $key

Return Value

bool

at line line 2770
void setAttribute(string $key, mixed $value)

Set a given attribute on the model.

Parameters

string $key
mixed $value

Return Value

void

at line line 2804
bool hasSetMutator(string $key)

Determine if a set mutator exists for an attribute.

Parameters

string $key

Return Value

bool

at line line 2814
array getDates()

Get the attributes that should be converted to dates.

Return Value

array

at line line 2827
string fromDateTime(DateTime|int $value)

Convert a DateTime to a storable string.

Parameters

DateTime|int $value

Return Value

string

at line line 2919
Model replicate(array $except = null)

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

Parameters

array $except

Return Value

Model

at line line 2939
array getAttributes()

Get all of the current attributes on the model.

Return Value

array

at line line 2951
void setRawAttributes(array $attributes, bool $sync = false)

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

Parameters

array $attributes
bool $sync

Return Value

void

at line line 2965
array getOriginal(string $key = null, mixed $default = null)

Get the model's original attribute values.

Parameters

string $key
mixed $default

Return Value

array

at line line 2975
$this syncOriginal()

Sync the original attributes with the current.

Return Value

$this

at line line 2988
$this syncOriginalAttribute(string $attribute)

Sync a single original attribute with its current value.

Parameters

string $attribute

Return Value

$this

at line line 3001
bool isDirty(array|string|null $attributes = null)

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

Parameters

array|string|null $attributes

Return Value

bool

at line line 3022
array getDirty()

Get the attributes that have been changed since last sync.

Return Value

array

at line line 3062
array getRelations()

Get all the loaded relations for the instance.

Return Value

array

at line line 3073
mixed getRelation(string $relation)

Get a specified relationship.

Parameters

string $relation

Return Value

mixed

at line line 3085
$this setRelation(string $relation, mixed $value)

Set the specific relationship in the model.

Parameters

string $relation
mixed $value

Return Value

$this

at line line 3098
$this setRelations(array $relations)

Set the entire relations array on the model.

Parameters

array $relations

Return Value

$this

at line line 3110
Connection getConnection()

Get the database connection for the model.

Return Value

Connection

at line line 3120
string getConnectionName()

Get the current connection name for the model.

Return Value

string

at line line 3131
$this setConnection(string $name)

Set the connection associated with the model.

Parameters

string $name

Return Value

$this

at line line 3144
static Connection resolveConnection(string $connection = null)

Resolve a connection instance.

Parameters

string $connection

Return Value

Connection

at line line 3154
static ConnectionResolverInterface getConnectionResolver()

Get the connection resolver instance.

at line line 3165
static void setConnectionResolver(ConnectionResolverInterface $resolver)

Set the connection resolver instance.

Parameters

ConnectionResolverInterface $resolver

Return Value

void

at line line 3175
static void unsetConnectionResolver()

Unset the connection resolver for models.

Return Value

void

at line line 3185
static Dispatcher getEventDispatcher()

Get the event dispatcher instance.

Return Value

Dispatcher

at line line 3196
static void setEventDispatcher(Dispatcher $dispatcher)

Set the event dispatcher instance.

Parameters

Dispatcher $dispatcher

Return Value

void

at line line 3206
static void unsetEventDispatcher()

Unset the event dispatcher for models.

Return Value

void

at line line 3216
array getMutatedAttributes()

Get the mutated attributes for a given instance.

Return Value

array

at line line 3234
static void cacheMutatedAttributes(string $class)

Extract and cache all the mutated attributes of a class.

Parameters

string $class

Return Value

void

at line line 3261
mixed __get(string $key)

Dynamically retrieve attributes on the model.

Parameters

string $key

Return Value

mixed

at line line 3273
void __set(string $key, mixed $value)

Dynamically set attributes on the model.

Parameters

string $key
mixed $value

Return Value

void

at line line 3284
bool offsetExists(mixed $offset)

Determine if the given attribute exists.

Parameters

mixed $offset

Return Value

bool

at line line 3295
mixed offsetGet(mixed $offset)

Get the value for a given offset.

Parameters

mixed $offset

Return Value

mixed

at line line 3307
void offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

at line line 3318
void offsetUnset(mixed $offset)

Unset the value for a given offset.

Parameters

mixed $offset

Return Value

void

at line line 3329
bool __isset(string $key)

Determine if an attribute exists on the model.

Parameters

string $key

Return Value

bool

at line line 3341
void __unset(string $key)

Unset an attribute on the model.

Parameters

string $key

Return Value

void

at line line 3353
mixed __call(string $method, array $parameters)

Handle dynamic method calls into the model.

Parameters

string $method
array $parameters

Return Value

mixed

at line line 3372
static mixed __callStatic(string $method, array $parameters)

Handle dynamic static method calls into the method.

Parameters

string $method
array $parameters

Return Value

mixed

at line line 3384
string __toString()

Convert the model to its string representation.

Return Value

string

at line line 3394
void __wakeup()

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

Return Value

void