BaseForFactory<T extends Model<T>> class
abstract
Properties
-
baseName
→ String?
-
final
-
connection
→ DriverAdapter?
-
The driver/connection associated with this model, if any.
no setterinherited
-
connectionResolver
→ ConnectionResolver?
-
The resolver attached to this model, when present.
no setterinherited
-
definition
→ ModelDefinition<T>?
-
Typed accessor to the attached
ModelDefinition, when available.
Returns null for untracked models (they don't have attached definitions).
no setterinherited
-
exists
→ bool
-
Whether this model has been persisted (loaded or saved).
no setterinherited
-
hasConnection
→ bool
-
Whether a resolver/connection has been attached.
no setterinherited
-
hasDefinition
→ bool
-
Whether a
ModelDefinition has been attached to this instance.
Always false for untracked models.
no setterinherited
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
id
→ int
-
final
-
loadedRelationNames
→ Set<String>
-
Returns names of all loaded relations.
no setterinherited
-
loadedRelations
→ Map<String, dynamic>
-
Returns a snapshot of all currently loaded relations.
no setterinherited
-
relations
→ Map<String, dynamic>
-
Shorthand alias for
loadedRelations.
no setterinherited
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
timestamps
→ bool
-
Whether automatic timestamps are enabled for this model instance.
no setterinherited
-
touches
→ TouchesList
-
Relation names that should be touched when this model is saved.
no setterinherited
-
usesTimestamps
→ bool
-
Whether this model uses timestamps after applying ignore scopes.
no setterinherited
Methods
-
asMap({ValueCodecRegistry? registry})
→ Map<String, Object?>
-
Alias for
toRecord for ergonomics when bridging to JSON/Maps.
inherited
-
associate(String relationName, Model<Model> parent)
→ Future<T>
-
Associates a belongsTo parent model and updates the foreign key.
inherited
-
attach(String relationName, List ids, {Map<String, dynamic>? pivotData})
→ Future<T>
-
Attaches related models in a manyToMany relationship.
inherited
-
attachConnection(DriverAdapter driver)
→ void
-
Legacy helper for manually attaching a driver outside a resolver.
inherited
-
attachConnectionResolver(ConnectionResolver resolver)
→ void
-
Assigns the resolver responsible for this model instance.
inherited
-
clearQueuedJsonMutations()
→ void
-
Clears any queued JSON mutations without persisting them.
inherited
-
clearRelations()
→ void
-
Clears all cached relations.
inherited
-
createManyQuietlyRelation<TRelated extends Model<TRelated>>(String relationName, List<Object> attributesList)
→ Future<List<TRelated>>
-
Creates multiple related models without firing model events.
inherited
-
createManyRelation<TRelated extends Model<TRelated>>(String relationName, List<Object> attributesList)
→ Future<List<TRelated>>
-
Creates multiple related models through a hasMany relationship.
inherited
-
createQuietlyRelation<TRelated extends Model<TRelated>>(String relationName, Object attributes)
→ Future<TRelated>
-
Creates a related model without firing model events.
inherited
-
createRelation<TRelated extends Model<TRelated>>(String relationName, Object attributes)
→ Future<TRelated>
-
Creates a related model through a hasOne or hasMany relationship.
inherited
-
delete({bool force = false})
→ Future<void>
-
Deletes the record. Soft-deletes when supported unless
force is true.
inherited
-
describeMutation(MutationPlan plan)
→ StatementPreview
-
Returns the statement preview for a write
plan.
inherited
-
describeQuery(QueryPlan plan)
→ StatementPreview
-
Returns the statement preview for a read
plan.
inherited
-
detach(String relationName, [List? ids])
→ Future<T>
-
Detaches related models in a manyToMany relationship.
inherited
-
dissociate(String relationName)
→ Future<T>
-
Dissociates a belongsTo parent model and clears the foreign key.
inherited
-
expectDefinition()
→ ModelDefinition<T>
-
Ensures the definition metadata is available, throwing when missing.
inherited
-
fill(Object attributes, {bool strict = false, ValueCodecRegistry? registry})
→ Model<T>
-
Mass assigns
attributes, honoring fillable/guarded metadata.
inherited
-
fillIfAbsent(Object attributes, {bool strict = false, ValueCodecRegistry? registry})
→ Model<T>
-
Mass assigns only values that are currently absent.
inherited
-
forceDelete()
→ Future<void>
-
Hard-deletes the record, bypassing soft-delete flows entirely.
inherited
-
forceFill(Object attributes, {ValueCodecRegistry? registry})
→ Model<T>
-
Temporarily disables mass-assignment protection while
callback runs.
inherited
-
fresh({bool withTrashed = false, Iterable<String>? withRelations})
→ Future<T>
-
Returns a fresh instance of this model from the database.
inherited
-
getRelation<T>(String name)
→ T?
-
Retrieves a cached relation value typed as
T.
inherited
-
getRelationList<T>(String name)
→ List<T>
-
Retrieves a list relation typed as
T.
inherited
-
isDifferentFrom(Model<Model>? other)
→ bool
-
Determine if two models are different.
inherited
-
isSameAs(Model<Model>? other)
→ bool
-
Determine if two models represent the same database record.
inherited
-
jsonPatch(String column, Map<String, Object?> delta)
→ void
-
Queues a JSON patch merge for
column using the provided delta map.
inherited
-
jsonSet(String selector, Object? value)
→ void
-
Queues a JSON update using Laravel-style selector syntax
(
column->path). Call save to persist the change.
inherited
-
jsonSetPath(String column, String path, Object? value)
→ void
-
Queues a JSON update by explicitly providing
path relative to column.
inherited
-
load(String relation, [PredicateCallback<OrmEntity>? constraint])
→ Future<T>
-
Lazily loads a relation on this model instance.
inherited
-
loadAvg(String relation, String column, {String? alias, PredicateCallback<OrmEntity>? constraint})
→ Future<T>
-
Lazily loads the average of a column in a relation.
inherited
-
loadCount(String relation, {String? alias, PredicateCallback<OrmEntity>? constraint})
→ Future<T>
-
Lazily loads the count of a relation.
inherited
-
loadExists(String relation, {String? alias, PredicateCallback<OrmEntity>? constraint})
→ Future<T>
-
Lazily loads the existence of a relation.
inherited
-
loadMany(Map<String, PredicateCallback<OrmEntity>?> relations)
→ Future<T>
-
Lazily loads multiple relations with optional constraints.
inherited
-
loadMax(String relation, String column, {String? alias, PredicateCallback<OrmEntity>? constraint})
→ Future<T>
-
Lazily loads the maximum value of a column in a relation.
inherited
-
loadMin(String relation, String column, {String? alias, PredicateCallback<OrmEntity>? constraint})
→ Future<T>
-
Lazily loads the minimum value of a column in a relation.
inherited
-
loadMissing(Iterable<String> relations)
→ Future<T>
-
Lazily loads multiple relations that haven't been loaded yet.
inherited
-
loadSum(String relation, String column, {String? alias, PredicateCallback<OrmEntity>? constraint})
→ Future<T>
-
Lazily loads the sum of a column in a relation.
inherited
-
markAsExisting()
→ void
-
Marks this model as existing in the database.
inherited
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh({bool withTrashed = false, Iterable<String>? withRelations})
→ Future<T>
-
Reloads the latest row from the database, optionally including trashed.
inherited
-
relationLoaded(String name)
→ bool
-
Checks if a relation has been loaded.
inherited
-
replicate({List<String>? except})
→ T
-
Clone the model into a new, non-existing instance.
inherited
-
restore()
→ Future<void>
-
Restores a soft-deleted record.
inherited
-
runMutation(MutationPlan plan)
→ Future<MutationResult>
-
Runs a write
plan through the attached resolver.
inherited
-
runSelect(QueryPlan plan)
→ Future<List<Map<String, Object?>>>
-
Runs a read
plan through the attached resolver.
inherited
-
save({bool returning = true, bool touch = true})
→ Future<T>
-
Persists the model using the active resolver and returns the stored copy.
inherited
-
saveManyRelation<TRelated extends Model<TRelated>>(String relationName, List<TRelated> related)
→ Future<List<TRelated>>
-
Saves multiple related models through a hasMany relationship.
inherited
-
saveRelation<TRelated extends Model<TRelated>>(String relationName, TRelated related)
→ Future<TRelated>
-
Saves a related model through a hasOne or hasMany relationship.
inherited
-
setRelation(String name, dynamic value)
→ void
-
Sets a relation value and marks it as loaded.
inherited
-
setRelations(Map<String, dynamic> relations)
→ void
-
Bulk sets multiple relations at once.
inherited
-
sync(String relationName, List ids, {Map<String, dynamic>? pivotData})
→ Future<T>
-
Syncs a manyToMany relationship to match the given IDs exactly.
inherited
-
syncRelationsFromQueryRow(Map<String, dynamic> rowRelations)
→ void
-
Syncs relations from a
QueryRow into this model's cache.
inherited
-
syncWithoutDetaching(String relationName, List ids, {Map<String, dynamic>? pivotData})
→ Future<T>
-
Syncs a manyToMany relationship without detaching existing records.
inherited
-
syncWithPivotValues(String relationName, List ids, Map<String, dynamic> pivotData)
→ Future<T>
-
Syncs a manyToMany relationship with the same pivot data for all records.
inherited
-
toArray({ValueCodecRegistry? registry, bool includeHidden = false})
→ Map<String, Object?>
-
Converts the model into a metadata-aware map, honoring hidden/visible lists.
inherited
-
toggle(String relationName, List ids, {Map<String, dynamic>? pivotData})
→ Future<T>
-
Toggles the attachment of related models in a manyToMany relationship.
inherited
-
toJson({ValueCodecRegistry? registry, bool includeHidden = false})
→ String
-
Converts the model instance into JSON, applying the attribute metadata.
inherited
-
toRecord({ValueCodecRegistry? registry})
→ Map<String, Object?>
-
Serializes the model into a column map via its codec/definition.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited
-
touch([String? attribute])
→ Future<bool>
-
Touches the model's timestamp column and persists the change.
inherited
-
touchOwners()
→ Future<void>
-
Touches the owning relations of the model.
inherited
-
unsetRelation(String name)
→ void
-
Removes a relation from the cache and marks it as not loaded.
inherited
-
updateExistingPivot(String relationName, dynamic id, Map<String, dynamic> pivotData)
→ Future<T>
-
Updates pivot table attributes for an existing pivot record.
inherited
-
withoutTimestamps<T>(T callback())
→ T
-
Disable timestamps for this model's runtime type during the callback scope.
inherited
-
withoutTouching<T>(T callback())
→ T
-
Disable touching for this model's runtime type during the callback scope.
inherited