AuthenticatableModel mixin base

Default Authenticatable implementation for models:

final class User extends Model with AuthenticatableModel { ... }
Superclass constraints
Implemented types
Available extensions

Properties

attributes → Map<String, Object?>
Raw stored attributes (after set casts).
no setterinherited
authIdentifier → Object
Primary identifier (stored in tokens and sessions).
no setteroverride
authIdentifierName → String
Column name of authIdentifier (id).
no setteroverride
authPassword → String?
Hashed password, or null for password-less accounts.
no setteroverride
authPasswordName → String
Column name of authPassword (password).
no setteroverride
database → DatabaseManager
The database manager this model was loaded through (or the container's).
no setterinherited
exists ↔ bool
Whether the model is persisted.
getter/setter pairinherited
hashCode → int
The hash code for this object.
no setterinherited
key → Object?
Primary key value.
no setterinherited
modelDefinition → ModelDefinition<Model>
Static metadata; override as ModelDefinition<User> get modelDefinition.
no setterinherited
original → Map<String, Object?>
Attributes as last synced with the database.
no setterinherited
pivot ↔ Map<String, Object?>?
Pivot columns when loaded through a BelongsToMany relation.
getter/setter pairinherited
relations → Map<String, Object?>
Loaded relations by name.
no setterinherited
rememberToken → String?
"Remember me" token (session guard, T2).
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
table → String
The model's table.
no setterinherited
trashed → bool
Whether the model is soft deleted.
no setterinherited
wasRecentlyCreated ↔ bool
Whether the model was inserted during the current request/operation.
getter/setter pairinherited

Methods

append(List<String> attributes) → Model
Adds the accessors attributes to toJson for this instance.
inherited
attach(String name, Object ids, {Map<String, Object?> pivot = const {}}) → Future<void>
Attaches related through a BelongsToMany relation name.
inherited
attachDatabase(DatabaseManager? db) → void
Attaches a database manager (used by queries and tests).
inherited
decrement(String column, [num amount = 1, Map<String, Object?> extra = const {}]) → Future<int>
Subtracts amount from column in the database and on the model.
inherited
delete() → Future<bool>
Deletes (soft deletes when configured).
inherited
deleteQuietly() → Future<bool>
Deletes without firing events.
inherited
detach(String name, [Object? ids]) → Future<int>
Detaches ids (or all) through a BelongsToMany relation name.
inherited
fill(Map<String, Object?> attributes) → Model
Mass assigns attributes honouring fillable/guarded.
inherited
fireEvent(ModelEvent event) → Future<bool>
Fires event (used by queries for retrieved).
inherited
forceDelete() → Future<bool>
Permanently deletes a soft-deletable model.
inherited
forceFill(Map<String, Object?> attributes) → Model
Mass assigns attributes ignoring fillable/guarded.
inherited
fresh() → Future<Model?>
A fresh copy from the database (or null when gone).
inherited
getAttr<R>(String key) → R
Typed attribute read with casts and accessors applied.
inherited
getChanges() → Map<String, Object?>
The attributes the last save() wrote (Laravel's getChanges()): what an updated or created observer sees changed, since by then original already matches attributes.
inherited
getDirty() → Map<String, Object?>
Attributes that changed since the last sync.
inherited
hasAttribute(String key) → bool
Whether key has a value in the attribute bag.
inherited
hydrateFrom(Map<String, Object?> row, {DatabaseManager? db}) → void
Replaces every attribute from a database row. Called by the query.
inherited
increment(String column, [num amount = 1, Map<String, Object?> extra = const {}]) → Future<int>
Atomically increments column in the database and locally.
inherited
isClean([String? key]) → bool
Whether key (or any attribute when null) is unchanged since the model was loaded or saved.
inherited
isDirty([String? key]) → bool
Whether key (or any attribute) differs from the database.
inherited
isNot(Model other) → bool
Whether other is a different row than this model.
inherited
isSameAs(Model other) → bool
Whether other is the same row.
inherited
load(Object relations) → Future<Model>
Loads relations (list or map with constraints) onto this model.
inherited
loadMissing(List<String> relations) → Future<Model>
Loads the relations that are not loaded yet.
inherited
makeHidden(List<String> attributes) → Model
Hides attributes from toJson for this instance.
inherited
makeVisible(List<String> attributes) → Model
Shows attributes in toJson for this instance, even when hidden.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifications({bool unreadOnly = false}) → Future<List<DatabaseNotification>>

Available on Model, provided by the NotifiableModel extension

This model's stored notifications, newest first.
notify(Notification notification) → Future<void>

Available on Model, provided by the NotifiableModel extension

Sends notification to this model.
refresh() → Future<Model>
Reloads attributes (and drops loaded relations) from the database.
inherited
A loaded relation (List<Post> / ModelCollection<Post> for *-many, the model or null for *-one). Throws when not loaded and preventLazyLoading is on.
inherited
relatedQuery<R extends Model>(String name) → ModelQuery<R>
A query scoped to the relation name (user.relatedQuery<Post>('posts')).
inherited
relationLoaded(String name) → bool
Whether name was loaded.
inherited
replicate({List<String> except = const []}) → Model
Copy without key and timestamps (Laravel replicate).
inherited
restore() → Future<bool>
Restores a soft-deleted model.
inherited
save() → Future<bool>
Inserts or updates the model. Returns false when an observer cancels.
inherited
saveQuietly() → Future<bool>
Saves without firing events.
inherited
setAttr(String key, Object? value) → void
Attribute write with mutators and casts applied.
inherited
setRelation(String name, Object? value) → void
Stores a loaded relation result.
inherited
sync(String name, Object ids, {bool detaching = true}) → Future<Map<String, List<Object?>>>
Syncs pivot rows through a BelongsToMany relation name.
inherited
syncOriginal() → void
Marks the current attributes as the persisted state.
inherited
syncWithoutDetaching(String name, Object ids) → Future<Map<String, List<Object?>>>
sync that leaves the other rows.
inherited
toggle(String name, Object ids) → Future<Map<String, List<Object?>>>
Attaches the ids that are not attached, detaches those that are.
inherited
toJson() → Map<String, Object?>
JSON representation: visible attributes, appends and loaded relations (relation names snake_cased as given), in the order Laravel 8 to 13 write them (HasAttributes::attributesToArray): an append that names an existing attribute replaces it in place, and a Cast.dateTimeFormat attribute is written in its format, in UTC.
inherited
toMap() → Map<String, Object?>
Attributes with casts applied (no hidden filtering).
inherited
toResponse(Request request) → Response
The response for request.
inherited
toString() → String
A string representation of this object.
inherited
touch() → Future<bool>
Updates the updated_at timestamp.
inherited
update(Map<String, Object?> attributes) → Future<bool>
Mass assigns and saves.
inherited
updateExistingPivot(String name, Object id, Map<String, Object?> attributes) → Future<int>
Updates the pivot row of id.
inherited
updateQuietly(Map<String, Object?> attributes) → Future<bool>
Mass assigns and saves without firing events.
inherited
wasChanged([String? key]) → bool
Attributes changed by the last save().
inherited
withoutEvents<R>(Future<R> body()) → Future<R>
Runs body with model events disabled.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](String key) → Object?
The attribute key, cast: user['email'].
inherited
operator []=(String key, Object? value) → void
Sets the attribute key: user['email'] = 'a@b.c'.
inherited