Authenticatable mixin

The Authenticatable Mixin.

This mixin should be applied to User models to make them compatible with the Magic Authentication system. It provides the necessary interface for Guards to identify and authenticate users.

Usage

class User extends Model with HasTimestamps, InteractsWithPersistence, Authenticatable {
  @override String get table => 'users';
  @override String get resource => 'users';
}

How It Works

The mixin exposes:

Guards use these properties to persist and retrieve the authenticated user.

Superclass constraints

Properties

appends → List<String>
The accessors to append to the model's array form.
no setterinherited
attributes → Map<String, dynamic>
Get all attributes as a Map.
no setterinherited
authIdentifier → dynamic
Get the unique identifier for the user.
no setter
authIdentifierName → String
Get the name of the unique identifier column.
no setter
authPassword → String?
Get the password for the user.
no setter
casts → Map<String, dynamic>
The attributes that should be cast.
no setterinherited
exists ↔ bool
Indicates if the model exists in the database.
getter/setter pairinherited
fillable → List<String>
The attributes that are mass assignable.
no setterinherited
guarded → List<String>
The attributes that are guarded from mass assignment.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hidden → List<String>
The attributes that should be hidden for serialization.
no setterinherited
id ↔ dynamic
Get the model's primary key value.
getter/setter pairinherited
incrementing → bool
Indicates if the primary key is auto-incrementing.
no setterinherited
primaryKey → String
The primary key for the model.
no setterinherited
relations → Map<String, Model Function()>
The model relationships for automatic casting.
no setterinherited
resource → String
The API resource name for remote operations.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
table → String
The table associated with the model.
no setterinherited
useLocal → bool
Whether to use local database persistence.
no setterinherited
useRemote → bool
Whether to use remote API persistence.
no setterinherited
visible → List<String>
The attributes that should be visible for serialization.
no setterinherited
wasRecentlyCreated ↔ bool
Indicates if the model was recently created.
getter/setter pairinherited

Methods

append(List<String> attributes) → Model
Append accessors to the model.
inherited
fill(Map<String, dynamic> attributes, {bool strict = false}) → void
Fill the model with an array of attributes.
inherited
get<T>(String key, {T? defaultValue}) → T?
Get an attribute value with optional default and type casting.
inherited
getAttribute(String key) → dynamic
Get an attribute from the model.
inherited
getDirty() → Map<String, dynamic>
Get the dirty attributes (those that have changed).
inherited
getRelation<T extends Model>(String key) → T?
Get a single related model.
inherited
getRelations<T extends Model>(String key) → List<T>
Get a list of related models.
inherited
has(String key) → bool
Check if an attribute exists and is not null.
inherited
isDirty([String? attribute]) → bool
Create a model instance from a Map.
inherited
makeHidden(List<String> attributes) → Model
Make attributes hidden.
inherited
makeVisible(List<String> attributes) → Model
Make attributes visible.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String key, dynamic value) → void
Set an attribute value.
inherited
setAttribute(String key, dynamic value) → void
Set an attribute on the model.
inherited
setRawAttributes(Map<String, dynamic> attributes, {bool sync = false}) → void
Set the model's raw attributes.
inherited
syncOriginal() → void
Sync the original attributes with the current.
inherited
toArray() → Map<String, dynamic>
Alias for toMap - Laravel-style naming.
inherited
toJson() → String
Convert the model to a JSON string.
inherited
toMap() → Map<String, dynamic>
Convert the model to a Map.
inherited
toString() → String
A string representation of this object.
inherited
updateTimestamps() → void
Update the model's timestamps.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited