BaseModel<T> class
abstract
Base model that all application models should extend.
- Annotations
-
- @Deprecated('Use KhademModel instead')
Constructors
Properties
-
appends
→ List<
String> -
Fields to append to the model when serializing.
no setter
-
casts
→ Map<
String, Type> -
Fields that should be cast to specific types.
no setter
-
computed
→ Map<
String, dynamic> -
Computed properties for the model.
no setter
-
fillable
→ List<
String> -
Fields allowed for mass assignment.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
Fields that should be hidden when serializing.
no setter
- id ↔ int?
-
ID of the model.
getter/setter pair
- modelName → String
-
The name of the model.
no setter
-
query
→ QueryBuilderInterface<
T> -
Create query builder using current default connection.
no setter
-
rawData
→ Map<
String, dynamic> -
no setter
-
relations
→ Map<
String, RelationDefinition< KhademModel> > -
Holds all relations
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tableName → String
-
Database table name.
no setter
Methods
-
copyWith(
{int? id}) → BaseModel -
delete(
) → Future< void> - Deletes the model.
-
fireEvent(
String eventNameBuilder(String)) → Future< void> - Triggers a model event.
-
fromJson(
Map< String, dynamic> json) → void - Fills model data from a map (e.g., database).
-
getField(
String key) → dynamic - Override this method to define how each field is accessed.
-
getRelation(
String key) → dynamic -
newFactory(
Map< String, dynamic> data) → T -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
save(
) → Future< void> - Saves the model to the database.
-
setField(
String key, dynamic value) → void - Override this method to define how each field is set.
-
setRelation(
String key, dynamic value) → void -
toDatabaseJson(
) → Map< String, dynamic> - Converts model data to JSON for saving to database. This does NOT hide fields like password.
-
toJson(
) → Map< String, dynamic> -
Converts model to JSON for API responses.
This respects
hidden,appends, andcomputed. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited