Repository navigation
Internals Models
Framework Internals · Developer guide
Model extends DatabaseManager and adds primary-key state, declared/dynamic attributes and ORM snapshots. selectByID resolves table/key defaults, fetches one row and clears prior hydration state; hydrateRow assigns attributes, establishes table/key/id, resolves relations with recursion protection and syncs originals.
Persistence collects initialized public properties and dynamicData, excludes internal/blacklisted/relation fields, optionally intersects writableAttributes, serializes JSON casts/backed enums, and updates/inserts through DatabaseManager. fill uses explicit fillableAttributes; fromArray is trusted assignment. hiddenAttributes affects output only. Casts include int/float/string/bool/json; unsupported casts, invalid booleans or internal-property assignment fail.
save requires model_id, excludes the key from update, adds a timestamp for registered updated_on, and updates all allowed fields. saveModel inserts and sets the key; deleteModel rejects missing key and clears it after success. Exceptions are wrapped in ModelCRUDException/ModelCreationException. getModels clones/hydrates already-fetched rows; firstModelOrFail throws for no result. newQuery preserves connection/cache and resets builder/attributes.
Relations are configured through with/belongsTo/hasMany interfaces, not generic dynamic relationship methods. The row's foreign key or local key determines related lookup. Default relation loading shares the connection before lookup; inConstructor modes can perform constructor queries first. Single missing relations become null; has-many populates arrays. Lazy __get supports the with alias, caches unknown missing fields as null and prevents accidental persistence of those misses.
ModelCollection immediately selects all rows, obtains the concrete model class, creates clones using hydrateRow, and wraps them in an ObjectCollection. It implements IteratorAggregate/Countable and avoids repeat lookup queries on normal hydration. It is not a lazy database cursor or paginated query API.
-
Model-Model —
awt_src/classes/model/Model.php -
Model-ModelCollection —
awt_src/classes/model/ModelCollection.php -
Model-Exceptions-ModelCRUDException —
awt_src/classes/model/exceptions/ModelCRUDException.php -
Model-Exceptions-ModelCreationException —
awt_src/classes/model/exceptions/ModelCreationException.php -
Model-Interfaces-IRelationBelongs —
awt_src/classes/model/interfaces/IRelationBelongs.php -
Model-Interfaces-IRelationHasMany —
awt_src/classes/model/interfaces/IRelationHasMany.php -
Model-Interfaces-IRelationWith —
awt_src/classes/model/interfaces/IRelationWith.php
AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes