KhademModel<T> class
abstract
- Mixed-in types
-
- HasAttributes<
T> - HasEvents<
T> - HasRelations<
T> - InteractsWithDatabase<
T>
- HasAttributes<
Constructors
- KhademModel()
- Create a new instance of the model.
Properties
-
appends
→ Map<
String, dynamic> -
The accessors to append to the model's array form.
no setterinherited
-
attributes
→ Map<
String, dynamic> -
Get all of the current attributes on the model.
no setterinherited
-
casts
→ Map<
String, dynamic> -
The attributes that should be cast to native types.
no setterinherited
-
definedRelations
→ Map<
String, RelationDefinition< KhademModel> > -
The defined relationships for the model.
Override this to define relations.
no setterinherited
-
dispatchesEvents
→ Map<
ModelLifecycle, Event Function(T)> -
The event map for the model.
no setterinherited
- exists ↔ bool
-
getter/setter pairinherited
-
fillable
→ List<
String> -
The attributes that are mass assignable.
no setterinherited
-
guarded
→ List<
String> -
The attributes that aren't mass assignable.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
The attributes that should be hidden for serialization.
no setterinherited
- id ↔ int?
-
The primary key for the model.
getter/setter pairoverride
-
original
→ Map<
String, dynamic> -
Get the original attributes.
no setterinherited
- primaryKey → String
-
The primary key associated with the table.
no setteroverride
-
query
→ QueryBuilderInterface<
T> -
Get a new query builder for the model's table.
no setterinherited
-
relations
→ Map<
String, dynamic> -
Get all the loaded relations.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- table → String
-
The table associated with the model.
no setteroverride
- tableName → String
-
Alias for table.
no setteroverride
-
visible
→ List<
String> -
The attributes that should be visible in serialization.
no setterinherited
-
withCount
→ List<
String> -
The relationship counts that should be eager loaded on every query.
no setterinherited
- withRelations → List
-
The relationships that should be eager loaded on every query.
no setterinherited
Methods
-
all(
) → Future< List< T> > -
Get all models.
inherited
-
append(
List< String> attributes) → void -
Append attributes.
inherited
-
belongsTo<
R extends KhademModel< (R> >{required R factory(), required String foreignKey, String? ownerKey, dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define an inverse one-to-one or many-to-one relationship.
inherited
-
belongsToMany<
R extends KhademModel< (R> >{required String pivotTable, required String foreignPivotKey, required R factory(), String? parentKey, dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a many-to-many relationship.
inherited
-
castAttribute(
String key, dynamic value) → dynamic -
Cast an attribute to its declared Dart type.
inherited
-
decrement(
String column, [int amount = 1]) → Future< void> -
Decrement a column's value.
inherited
-
delete(
) → Future< bool> -
Delete the model from the database.
inherited
-
except(
List< String> keys) → Map<String, dynamic> -
Get all attributes except the given keys.
inherited
-
fill(
Map< String, dynamic> attributes) → T -
Fill the model with an array of attributes.
inherited
-
find(
dynamic id) → Future< T?> -
Find a model by its primary key.
inherited
-
findOrFail(
dynamic id) → Future< T> -
Find a model by its primary key or throw an exception.
inherited
-
fireModelEvent(
ModelLifecycle event, {bool halt = true}) → Future< bool> -
Fire a model lifecycle event.
inherited
-
forceFill(
Map< String, dynamic> attributes) → T -
Force fill the model with an array of attributes.
inherited
-
fresh(
[List< String> withRelations = const []]) → Future<T?> -
Get a fresh instance of the model from the database.
inherited
-
fromJson(
Map< String, dynamic> json) → void -
Initialize the model from a database record.
override
-
getAttribute(
String key) → dynamic -
Get an attribute from the model.
inherited
-
getDirty(
) → Map< String, dynamic> -
Get the attributes that have been changed since the last sync.
inherited
-
getKey(
) → dynamic -
inherited
-
getOriginal(
String key, [dynamic defaultValue]) → dynamic -
Get an original attribute value.
inherited
-
getRawAttribute(
String key, [dynamic defaultValue]) → dynamic -
Get a raw attribute without casting.
inherited
-
getRelation(
String relation) → dynamic -
Get a specified relationship.
inherited
-
hasAttribute(
String key) → bool -
Check if the model has a specific attribute.
inherited
-
hasCast(
String key) → bool -
Determine if an attribute has a cast.
inherited
-
hasMany<
R extends KhademModel< (R> >{required String foreignKey, required R factory(), String? localKey, dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a one-to-many relationship.
inherited
-
hasManyThrough<
R extends KhademModel< (R> >{required String throughTable, required String throughForeignKey, required R factory(), String? parentLocalKey, String throughLocalKey = 'id', dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a "has many through" relationship with clearer parameter names.
inherited
-
hasOne<
R extends KhademModel< (R> >{required String foreignKey, required R factory(), String? localKey, dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a one-to-one relationship.
inherited
-
hasOneThrough<
R extends KhademModel< (R> >{required String throughTable, required String throughForeignKey, required R factory(), String? parentLocalKey, String throughLocalKey = 'id', dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a "has one through" relationship with clearer parameter names.
inherited
-
hasOriginal(
String key) → bool -
Check if the model has a specific original attribute.
inherited
-
increment(
String column, [int amount = 1]) → Future< void> -
Increment a column's value.
inherited
-
isClean(
[dynamic attributes]) → bool -
Check if the model or specific attribute is clean.
inherited
-
isDirty(
[dynamic attributes]) → bool -
Check if the model or specific attribute is dirty.
inherited
-
isFillable(
String key) → bool -
Determine if the given attribute may be mass assigned.
inherited
-
load(
List< String> relations) → Future<T> -
Load the given relations.
inherited
-
loadMissing(
List< String> relations) → Future<T> -
Load the given relations if they are not already loaded.
inherited
-
makeHidden(
List< String> attributes) → void -
Make attributes hidden.
inherited
-
makeVisible(
List< String> attributes) → void -
Make attributes visible.
inherited
-
mergeAttributes(
Map< String, dynamic> attributes) → void -
Merge new attributes into the model.
inherited
-
morphedByMany<
R extends KhademModel< (R> >{required String morphName, required String pivotTable, required String foreignPivotKey, required R factory(), String parentKey = 'id', dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define the inverse of a polymorphic many-to-many relationship.
inherited
-
morphMany<
R extends KhademModel< (R> >{required String morphName, required R factory(), String? localKey, dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
inherited
-
morphOne<
R extends KhademModel< (R> >{required String morphName, required R factory(), String? localKey, dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
inherited
-
morphTo<
R extends KhademModel< (R> >{required String morphName, required R factory(), String ownerKey = 'id', dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a polymorphic inverse relationship (fixed target type).
inherited
-
morphToMany<
R extends KhademModel< (R> >{required String morphName, required String pivotTable, required String foreignPivotKey, required R factory(), String parentKey = 'id', dynamic query(QueryBuilderInterface)?}) → RelationDefinition< KhademModel> -
Define a polymorphic many-to-many relationship.
inherited
-
newFactory(
Map< String, dynamic> data) → T -
Create a new instance from a map.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
only(
List< String> keys) → Map<String, dynamic> -
Get a subset of attributes.
inherited
-
refresh(
) → Future< void> -
Refresh the model from the database.
inherited
-
relation(
String name) → Relation -
Get a relation instance.
inherited
-
relationLoaded(
String key) → bool -
Determine if the given relation is loaded.
inherited
-
save(
) → Future< bool> -
Save the model to the database.
inherited
-
setAttribute(
String key, dynamic value) → void -
Sync the 'id' property with attributes.
override
-
setRawAttribute(
String key, dynamic value) → void -
Set a raw attribute without casting.
inherited
-
setRelation(
String relation, dynamic value) → void -
Set the specific relationship in the model.
inherited
-
syncOriginal(
) → void -
Sync the original attributes with the current.
inherited
-
toDatabaseMap(
) → Map< String, dynamic> -
Prepare the model for database insertion/update.
inherited
-
toJson(
) → Map< String, dynamic> -
Convert the model instance to JSON.
inherited
-
toJsonAsync(
) → Future< Map< String, dynamic> > -
inherited
-
toMap(
) → Map< String, dynamic> -
Convert the model instance to a map.
inherited
-
toMapAsync(
) → Future< Map< String, dynamic> > -
Convert the model instance to a map, resolving any Future values.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
update(
Map< String, dynamic> attributes) → Future<bool> -
Update the model in the database.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited