Model (Database\Eloquent)
Model
class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable (View source)
Traits
HasAttributes |
HasEvents |
HasGlobalScopes |
HasRelationships |
HasTimestamps |
HidesAttributes |
GuardsAttributes |
Constants
CREATED_AT | The name of the "created at" column. |
UPDATED_AT | The name of the "updated at" column. |
Properties
static bool | $snakeAttributes | Indicates whether attributes are snake cased on arrays. | from HasAttributes |
static array | $manyMethods | The many to many relationship methods. | from HasRelationships |
bool | $timestamps | Indicates if the model should be timestamped. | from HasTimestamps |
bool | $incrementing | Indicates if the IDs are auto-incrementing. | |
bool | $exists | Indicates if the model exists. | |
bool | $wasRecentlyCreated | Indicates if the model was inserted during the current request lifecycle. |
Methods
array | attributesToArray() Convert the model's attributes to an array. | from HasAttributes |
array | relationsToArray() Get the model's relationships in array form. | from HasAttributes |
mixed | getAttribute(string $key) Get an attribute from the model. | from HasAttributes |
mixed | getAttributeValue(string $key) Get a plain attribute (not a relationship). | from HasAttributes |
mixed | getRelationValue(string $key) Get a relationship. | from HasAttributes |
bool | hasGetMutator(string $key) Determine if a get mutator exists for an attribute. | from HasAttributes |
$this | setAttribute(string $key, mixed $value) Set a given attribute on the model. | from HasAttributes |
bool | hasSetMutator(string $key) Determine if a set mutator exists for an attribute. | from HasAttributes |
$this | fillJsonAttribute(string $key, mixed $value) Set a given JSON attribute on the model. | from HasAttributes |
mixed | fromJson(string $value, bool $asObject = false) Decode the given JSON back into an array or object. | from HasAttributes |
string | fromDateTime(DateTime|int $value) Convert a DateTime to a storable string. | from HasAttributes |
array | getDates() Get the attributes that should be converted to dates. | from HasAttributes |
$this | setDateFormat(string $format) Set the date format used by the model. | from HasAttributes |
bool | hasCast(string $key, array|string|null $types = null) Determine whether an attribute should be cast to a native type. | from HasAttributes |
array | getCasts() Get the casts array. | from HasAttributes |
array | getAttributes() Get all of the current attributes on the model. | from HasAttributes |
$this | setRawAttributes(array $attributes, bool $sync = false) Set the array of model attributes. No checking is done. | from HasAttributes |
mixed|array | getOriginal(string|null $key = null, mixed $default = null) Get the model's original attribute values. | from HasAttributes |
$this | syncOriginal() Sync the original attributes with the current. | from HasAttributes |
$this | syncOriginalAttribute(string $attribute) Sync a single original attribute with its current value. | from HasAttributes |
bool | isDirty(array|string|null $attributes = null) Determine if the model or given attribute(s) have been modified. | from HasAttributes |
bool | isClean(array|string|null $attributes = null) Determine if the model or given attribute(s) have remained the same. | from HasAttributes |
array | getDirty() Get the attributes that have been changed since last sync. | from HasAttributes |
$this | append(array|string $attributes) Append attributes to query when building a query. | from HasAttributes |
$this | setAppends(array $appends) Set the accessors to append to model arrays. | from HasAttributes |
array | getMutatedAttributes() Get the mutated attributes for a given instance. | from HasAttributes |
static void | cacheMutatedAttributes(string $class) Extract and cache all the mutated attributes of a class. | from HasAttributes |
static void | observe(object|string $class) Register an observer with the Model. | from HasEvents |
array | getObservableEvents() Get the observable event names. | from HasEvents |
$this | setObservableEvents(array $observables) Set the observable event names. | from HasEvents |
void | addObservableEvents(array|mixed $observables) Add an observable event name. | from HasEvents |
void | removeObservableEvents(array|mixed $observables) Remove an observable event name. | from HasEvents |
static void | saving(Closure|string $callback) Register a saving model event with the dispatcher. | from HasEvents |
static void | saved(Closure|string $callback) Register a saved model event with the dispatcher. | from HasEvents |
static void | updating(Closure|string $callback) Register an updating model event with the dispatcher. | from HasEvents |
static void | updated(Closure|string $callback) Register an updated model event with the dispatcher. | from HasEvents |
static void | creating(Closure|string $callback) Register a creating model event with the dispatcher. | from HasEvents |
static void | created(Closure|string $callback) Register a created model event with the dispatcher. | from HasEvents |
static void | deleting(Closure|string $callback) Register a deleting model event with the dispatcher. | from HasEvents |
static void | deleted(Closure|string $callback) Register a deleted model event with the dispatcher. | from HasEvents |
static void | flushEventListeners() Remove all of the event listeners for the model. | from HasEvents |
static Dispatcher | getEventDispatcher() Get the event dispatcher instance. | from HasEvents |
static void | setEventDispatcher(Dispatcher $dispatcher) Set the event dispatcher instance. | from HasEvents |
static void | unsetEventDispatcher() Unset the event dispatcher for models. | from HasEvents |
static mixed | addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null) Register a new global scope on the model. | from HasGlobalScopes |
static bool | hasGlobalScope(Scope|string $scope) Determine if a model has a global scope. | from HasGlobalScopes |
static Scope|Closure|null | getGlobalScope(Scope|string $scope) Get a global scope registered with the model. | from HasGlobalScopes |
array | getGlobalScopes() Get the global scopes for this class instance. | from HasGlobalScopes |
HasOne | hasOne(string $related, string $foreignKey = null, string $localKey = null) Define a one-to-one relationship. | from HasRelationships |
MorphOne | morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null) Define a polymorphic one-to-one relationship. | from HasRelationships |
BelongsTo | belongsTo(string $related, string $foreignKey = null, string $ownerKey = null, string $relation = null) Define an inverse one-to-one or many relationship. | from HasRelationships |
MorphTo | morphTo(string $name = null, string $type = null, string $id = null) Define a polymorphic, inverse one-to-one or many relationship. | from HasRelationships |
static string | getActualClassNameForMorph(string $class) Retrieve the actual class name for a given morph class. | from HasRelationships |
HasMany | hasMany(string $related, string $foreignKey = null, string $localKey = null) Define a one-to-many relationship. | from HasRelationships |
HasManyThrough | hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null) Define a has-many-through relationship. | from HasRelationships |
MorphMany | morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null) Define a polymorphic one-to-many relationship. | from HasRelationships |
BelongsToMany | belongsToMany(string $related, string $table = null, string $foreignKey = null, string $relatedKey = null, string $relation = null) Define a many-to-many relationship. | from HasRelationships |
MorphToMany | morphToMany(string $related, string $name, string $table = null, string $foreignKey = null, string $relatedKey = null, bool $inverse = false) Define a polymorphic many-to-many relationship. | from HasRelationships |
MorphToMany | morphedByMany(string $related, string $name, string $table = null, string $foreignKey = null, string $relatedKey = null) Define a polymorphic, inverse many-to-many relationship. | from HasRelationships |
string | joiningTable(string $related) Get the joining table name for a many-to-many relation. | from HasRelationships |
bool | touches(string $relation) Determine if the model touches a given relation. | from HasRelationships |
void | touchOwners() Touch the owning relations of the model. | from HasRelationships |
string | getMorphClass() Get the class name for polymorphic relations. | from HasRelationships |
array | getRelations() Get all the loaded relations for the instance. | from HasRelationships |
mixed | getRelation(string $relation) Get a specified relationship. | from HasRelationships |
bool | relationLoaded(string $key) Determine if the given relation is loaded. | from HasRelationships |
$this | setRelation(string $relation, mixed $value) Set the specific relationship in the model. | from HasRelationships |
$this | setRelations(array $relations) Set the entire relations array on the model. | from HasRelationships |
array | getTouchedRelations() Get the relationships that are touched on save. | from HasRelationships |
$this | setTouchedRelations(array $touches) Set the relationships that are touched on save. | from HasRelationships |
bool | touch() Update the model's update timestamp. | from HasTimestamps |
$this | setCreatedAt(mixed $value) Set the value of the "created at" attribute. | from HasTimestamps |
$this | setUpdatedAt(mixed $value) Set the value of the "updated at" attribute. | from HasTimestamps |
Carbon | freshTimestamp() Get a fresh timestamp for the model. | from HasTimestamps |
string | freshTimestampString() Get a fresh timestamp for the model. | from HasTimestamps |
bool | usesTimestamps() Determine if the model uses timestamps. | from HasTimestamps |
string | getCreatedAtColumn() Get the name of the "created at" column. | from HasTimestamps |
string | getUpdatedAtColumn() Get the name of the "updated at" column. | from HasTimestamps |
array | getHidden() Get the hidden attributes for the model. | from HidesAttributes |
$this | setHidden(array $hidden) Set the hidden attributes for the model. | from HidesAttributes |
void | addHidden(array|string|null $attributes = null) Add hidden attributes for the model. | from HidesAttributes |
array | getVisible() Get the visible attributes for the model. | from HidesAttributes |
$this | setVisible(array $visible) Set the visible attributes for the model. | from HidesAttributes |
void | addVisible(array|string|null $attributes = null) Add visible attributes for the model. | from HidesAttributes |
$this | makeVisible(array|string $attributes) Make the given, typically hidden, attributes visible. | from HidesAttributes |
$this | makeHidden(array|string $attributes) Make the given, typically visible, attributes hidden. | from HidesAttributes |
array | getFillable() Get the fillable attributes for the model. | from GuardsAttributes |
$this | fillable(array $fillable) Set the fillable attributes for the model. | from GuardsAttributes |
array | getGuarded() Get the guarded attributes for the model. | from GuardsAttributes |
$this | guard(array $guarded) Set the guarded attributes for the model. | from GuardsAttributes |
static void | unguard(bool $state = true) Disable all mass assignable restrictions. | from GuardsAttributes |
static void | reguard() Enable the mass assignment restrictions. | from GuardsAttributes |
static bool | isUnguarded() Determine if current state is "unguarded". | from GuardsAttributes |
static mixed | unguarded(callable $callback) Run the given callable while being unguarded. | from GuardsAttributes |
bool | isFillable(string $key) Determine if the given attribute may be mass assigned. | from GuardsAttributes |
bool | isGuarded(string $key) Determine if the given key is guarded. | from GuardsAttributes |
bool | totallyGuarded() Determine if the model is totally guarded. | from GuardsAttributes |
void | __construct(array $attributes = array()) Create a new Eloquent model instance. | |
static void | clearBootedModels() Clear the list of booted models so they will be re-booted. | |
$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. | |
Model | newInstance(array $attributes = array(), bool $exists = false) Create a new instance of the given model. | |
Model | newFromBuilder(array $attributes = array(), string|null $connection = null) Create a new model instance that is existing. | |
static Builder | on(string|null $connection = null) Begin querying the model on a given connection. | |
static Builder | onWriteConnection() Begin querying the model on the write connection. | |
static Collection|Model[] | all(array|mixed $columns = array('*')) Get all of the models from the database. | |
static Builder|Model | with(array|string $relations) Begin querying a model with eager loading. | |
$this | load(array|string $relations) Eager load relations on the model. | |
bool | update(array $attributes = array(), array $options = 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. | |
bool | saveOrFail(array $options = array()) Save the model to the database using transaction. | |
static int | destroy(array|int $ids) Destroy the models for the given IDs. | |
bool|null | delete() Delete the model from the database. | |
bool|null | forceDelete() Force a hard delete on a soft deleted model. | |
static Builder | query() Begin querying the model. | |
Builder | newQuery() Get a new query builder for the model's table. | |
Builder|Model | newQueryWithoutScopes() Get a new query builder that doesn't have any global scopes. | |
Builder | newQueryWithoutScope(Scope|string $scope) Get a new query instance without a given scope. | |
Builder|Model | newEloquentBuilder(Builder $query) Create a new Eloquent query builder for the model. | |
Collection | newCollection(array $models = array()) Create a new Eloquent Collection instance. | |
Pivot | newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null) Create a new pivot model instance. | |
array | toArray() Convert the model instance to an array. | |
string | toJson(int $options) Convert the model instance to JSON. | |
array | jsonSerialize() Convert the object into something JSON serializable. | |
Model|null | fresh(array|string $with = array()) Reload a fresh model instance from the database. | |
void | refresh() Reload the current model instance with fresh attributes from the database. | |
Model | replicate(array $except = null) Clone the model into a new, non-existing instance. | |
bool | is(Model $model) Determine if two models have the same ID and belong to the same table. | |
Connection | 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|null $connection = null) Resolve a connection instance. | |
static ConnectionResolverInterface | getConnectionResolver() Get the connection resolver instance. | |
static void | setConnectionResolver(ConnectionResolverInterface $resolver) Set the connection resolver instance. | |
static void | unsetConnectionResolver() Unset the connection resolver for models. | |
string | getTable() Get the table associated with the model. | |
$this | setTable(string $table) Set the table associated with the model. | |
string | getKeyName() Get the primary key for the model. | |
$this | setKeyName(string $key) Set the primary key for the model. | |
string | getQualifiedKeyName() Get the table qualified key name. | |
string | getKeyType() Get the auto-incrementing key type. | |
$this | setKeyType(string $type) Set the data type for the primary key. | |
bool | getIncrementing() Get the value indicating whether the IDs are incrementing. | |
$this | setIncrementing(bool $value) Set whether IDs are incrementing. | |
mixed | getKey() Get the value of the model's primary key. | |
mixed | getQueueableId() Get the queueable identity for the entity. | |
mixed | getRouteKey() Get the value of the model's route key. | |
string | getRouteKeyName() Get the route key for the model. | |
string | getForeignKey() Get the default foreign key name for the model. | |
int | getPerPage() Get the number of models to return per page. | |
$this | setPerPage(int $perPage) Set the number of models to return per page. | |
mixed | __get(string $key) Dynamically retrieve attributes on the model. | |
void | __set(string $key, mixed $value) Dynamically set attributes on the model. | |
bool | offsetExists(mixed $offset) Determine if the given attribute exists. | |
mixed | offsetGet(mixed $offset) Get the value for a given offset. | |
void | offsetSet(mixed $offset, mixed $value) Set the value for a given offset. | |
void | offsetUnset(mixed $offset) Unset the value for a given offset. | |
bool | __isset(string $key) Determine if an attribute or relation exists on the model. | |
void | __unset(string $key) Unset an attribute on the model. | |
mixed | __call(string $method, array $parameters) Handle dynamic method calls into the model. | |
static mixed | __callStatic(string $method, array $parameters) Handle dynamic static method calls into the 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
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.
mixed getAttributeValue(string $key)
Get a plain attribute (not a relationship).
mixed getRelationValue(string $key)
Get a relationship.
bool hasGetMutator(string $key)
Determine if a get mutator exists for an attribute.
$this 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.
$this fillJsonAttribute(string $key, mixed $value)
Set a given JSON attribute on the model.
mixed fromJson(string $value, bool $asObject = false)
Decode the given JSON back into an array or object.
string fromDateTime(DateTime|int $value)
Convert a DateTime to a storable string.
array getDates()
Get the attributes that should be converted to dates.
$this setDateFormat(string $format)
Set the date format used by the model.
bool hasCast(string $key, array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
array getCasts()
Get the casts array.
array getAttributes()
Get all of the current attributes on the model.
$this setRawAttributes(array $attributes, bool $sync = false)
Set the array of model attributes. No checking is done.
mixed|array getOriginal(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
$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.
bool isClean(array|string|null $attributes = null)
Determine if the model or given attribute(s) have remained the same.
array getDirty()
Get the attributes that have been changed since last sync.
$this append(array|string $attributes)
Append attributes to query when building a query.
$this setAppends(array $appends)
Set the accessors to append to model arrays.
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.
static void observe(object|string $class)
Register an observer with the Model.
array getObservableEvents()
Get the observable event names.
$this setObservableEvents(array $observables)
Set the observable event names.
void addObservableEvents(array|mixed $observables)
Add an observable event name.
void removeObservableEvents(array|mixed $observables)
Remove an observable event name.
static void saving(Closure|string $callback)
Register a saving model event with the dispatcher.
static void saved(Closure|string $callback)
Register a saved model event with the dispatcher.
static void updating(Closure|string $callback)
Register an updating model event with the dispatcher.
static void updated(Closure|string $callback)
Register an updated model event with the dispatcher.
static void creating(Closure|string $callback)
Register a creating model event with the dispatcher.
static void created(Closure|string $callback)
Register a created model event with the dispatcher.
static void deleting(Closure|string $callback)
Register a deleting model event with the dispatcher.
static void deleted(Closure|string $callback)
Register a deleted model event with the dispatcher.
static void flushEventListeners()
Remove all of the event listeners for the model.
static Dispatcher getEventDispatcher()
Get the event dispatcher instance.
static void setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
static void unsetEventDispatcher()
Unset the event dispatcher for models.
static mixed addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null)
Register a new global scope on the model.
static bool hasGlobalScope(Scope|string $scope)
Determine if a model has a global scope.
static Scope|Closure|null getGlobalScope(Scope|string $scope)
Get a global scope registered with the model.
array getGlobalScopes()
Get the global scopes for this class instance.
HasOne hasOne(string $related, string $foreignKey = null, string $localKey = null)
Define a one-to-one relationship.
MorphOne morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null)
Define a polymorphic one-to-one relationship.
BelongsTo belongsTo(string $related, string $foreignKey = null, string $ownerKey = null, string $relation = null)
Define an inverse one-to-one or many relationship.
MorphTo morphTo(string $name = null, string $type = null, string $id = null)
Define a polymorphic, inverse one-to-one or many relationship.
static string getActualClassNameForMorph(string $class)
Retrieve the actual class name for a given morph class.
HasMany hasMany(string $related, string $foreignKey = null, string $localKey = null)
Define a one-to-many relationship.
HasManyThrough hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null)
Define a has-many-through relationship.
MorphMany morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null)
Define a polymorphic one-to-many relationship.
BelongsToMany belongsToMany(string $related, string $table = null, string $foreignKey = null, string $relatedKey = null, string $relation = null)
Define a many-to-many relationship.
MorphToMany morphToMany(string $related, string $name, string $table = null, string $foreignKey = null, string $relatedKey = null, bool $inverse = false)
Define a polymorphic many-to-many relationship.
MorphToMany morphedByMany(string $related, string $name, string $table = null, string $foreignKey = null, string $relatedKey = null)
Define a polymorphic, inverse many-to-many relationship.
string joiningTable(string $related)
Get the joining table name for a many-to-many relation.
bool touches(string $relation)
Determine if the model touches a given relation.
void touchOwners()
Touch the owning relations of the model.
string getMorphClass()
Get the class name for polymorphic relations.
array getRelations()
Get all the loaded relations for the instance.
mixed getRelation(string $relation)
Get a specified relationship.
bool relationLoaded(string $key)
Determine if the given relation is loaded.
$this setRelation(string $relation, mixed $value)
Set the specific relationship in the model.
$this setRelations(array $relations)
Set the entire relations array on the model.
array getTouchedRelations()
Get the relationships that are touched on save.
$this setTouchedRelations(array $touches)
Set the relationships that are touched on save.
bool touch()
Update the model's update timestamp.
$this setCreatedAt(mixed $value)
Set the value of the "created at" attribute.
$this setUpdatedAt(mixed $value)
Set the value of the "updated at" attribute.
Carbon freshTimestamp()
Get a fresh timestamp for the model.
string freshTimestampString()
Get a fresh timestamp for the model.
bool usesTimestamps()
Determine if the model uses timestamps.
string getCreatedAtColumn()
Get the name of the "created at" column.
string getUpdatedAtColumn()
Get the name of the "updated at" column.
array getHidden()
Get the hidden attributes for the model.
$this 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.
$this setVisible(array $visible)
Set the visible attributes for the model.
void addVisible(array|string|null $attributes = null)
Add visible attributes for the model.
$this makeVisible(array|string $attributes)
Make the given, typically hidden, attributes visible.
$this makeHidden(array|string $attributes)
Make the given, typically visible, attributes hidden.
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(bool $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.
void __construct(array $attributes = array())
Create a new Eloquent model instance.
static void clearBootedModels()
Clear the list of booted models so they will be re-booted.
$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.
Model newInstance(array $attributes = array(), bool $exists = false)
Create a new instance of the given model.
Model newFromBuilder(array $attributes = array(), string|null $connection = null)
Create a new model instance that is existing.
static Builder on(string|null $connection = null)
Begin querying the model on a given connection.
static Builder onWriteConnection()
Begin querying the model on the write connection.
static Collection|Model[] all(array|mixed $columns = array('*'))
Get all of the models from the database.
$this load(array|string $relations)
Eager load relations on the model.
bool update(array $attributes = array(), array $options = 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.
bool saveOrFail(array $options = array())
Save the model to the database using transaction.
static int destroy(array|int $ids)
Destroy the models for the given IDs.
bool|null delete()
Delete the model from the database.
bool|null forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when trait is missing.
static Builder query()
Begin querying the model.
Builder newQuery()
Get a new query builder for the model's table.
Collection newCollection(array $models = array())
Create a new Eloquent Collection instance.
Pivot newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null)
Create a new pivot model instance.
array toArray()
Convert the model instance to an array.
string toJson(int $options)
Convert the model instance to JSON.
array jsonSerialize()
Convert the object into something JSON serializable.
Model|null fresh(array|string $with = array())
Reload a fresh model instance from the database.
void refresh()
Reload the current model instance with fresh attributes from the database.
Model replicate(array $except = null)
Clone the model into a new, non-existing instance.
bool is(Model $model)
Determine if two models have the same ID and belong to the same table.
Connection 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|null $connection = null)
Resolve a connection instance.
static ConnectionResolverInterface getConnectionResolver()
Get the connection resolver instance.
static void setConnectionResolver(ConnectionResolverInterface $resolver)
Set the connection resolver instance.
static void unsetConnectionResolver()
Unset the connection resolver for models.
string getTable()
Get the table associated with the model.
$this setTable(string $table)
Set the table associated with the model.
string getKeyName()
Get the primary key for the model.
$this setKeyName(string $key)
Set the primary key for the model.
string getQualifiedKeyName()
Get the table qualified key name.
string getKeyType()
Get the auto-incrementing key type.
$this setKeyType(string $type)
Set the data type for the primary key.
bool getIncrementing()
Get the value indicating whether the IDs are incrementing.
$this setIncrementing(bool $value)
Set whether IDs are incrementing.
mixed getKey()
Get the value of the model's primary key.
mixed getQueueableId()
Get the queueable identity for the entity.
mixed getRouteKey()
Get the value of the model's route key.
string getRouteKeyName()
Get the route key for the model.
string getForeignKey()
Get the default foreign key name for the model.
int getPerPage()
Get the number of models to return per page.
$this setPerPage(int $perPage)
Set the number of models to return per page.
mixed __get(string $key)
Dynamically retrieve attributes on the model.
void __set(string $key, mixed $value)
Dynamically set attributes on the model.
bool offsetExists(mixed $offset)
Determine if the given attribute exists.
mixed offsetGet(mixed $offset)
Get the value for a given offset.
void offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
void offsetUnset(mixed $offset)
Unset the value for a given offset.
bool __isset(string $key)
Determine if an attribute or relation exists on the model.
void __unset(string $key)
Unset an attribute on the model.
mixed __call(string $method, array $parameters)
Handle dynamic method calls into the model.
static mixed __callStatic(string $method, array $parameters)
Handle dynamic static method calls into the 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.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.4/Illuminate/Database/Eloquent/Model.html