Data model — Map
A Map is a named collection of Locations and Sets (Categories) that backs a Finder. Every Finder has exactly one Map, created automatically when the Finder is created.
Table: maps
| Column | Type | Nullable | Description |
|---|---|---|---|
| id | bigint (auto-increment) | no | Primary key |
| title | varchar | no | Map name; mirrors the parent Finder’s title on auto-creation |
| description | text | yes | Optional freetext description; set to "Internal backing map for finder scope." on auto-creation |
| created_at | timestamp | no | Laravel auto-managed |
| updated_at | timestamp | no | Laravel auto-managed |
Relations
- belongsToMany
Finder— viafinder_mappivot. In normal operation this is a 1:1 relationship — one Map per Finder. The pivot schema enforcesfinder_idandmap_idwith cascading deletes. - belongsToMany
Set— viamap_setpivot. Sets (called “Categories” in the UI) belonging to this Map. - belongsToMany
Location— viamap_locationpivot (added in migration2026_04_17). The locations that this Map surfaces to its Finder. - belongsToMany
Workspace— viaworkspace_map/map_workspacepivot. Associates the Map with workspace(s). - belongsToMany
User— viamap_userpivot (owners). Returns onlyusers.idfor performance.
Paired Finder creation
A Map is always created as a side-effect of Finder creation, never independently. The logic lives in Finder::ensureBackingMap() (app/Models/Finder.php):
- A new
Mapis created withtitlecopied from the Finder (or"Finder {id}"if the Finder has no title yet). - The Map inherits the Finder’s owners (
finder_user→map_user) and workspaces viasyncWithoutDetaching. - The Map is attached to the Finder via the
finder_mappivot. - The Map’s description is set to
"Internal backing map for finder scope.".
Because ensureBackingMap is idempotent (wrapped in a DB transaction with an empty-check), it is safe to call repeatedly. It also handles the edge case where a Finder accumulated multiple Maps — it merges their sets and locations into the lowest-id Map and removes the extras.
See also: Finder data model for the full ensureBackingMap algorithm.
Computed / virtual attributes
None. The Map model has no $appends, no casts beyond defaults, and no overridden toArray.
Cross-links
- Finder data model — paired 1:1 relationship and auto-creation logic
- Set data model — Categories attached to Maps
- Location data model
- API reference — Maps