2.5 KiB
2.5 KiB
Current DB & Models Analysis — 2026-02-10
Summary
content_typesis the master namespace (see screenshot). Rows: e.g. id=1 Photography (slugphotography), id=2 Wallpapers, id=3 Skins, id=544 Members.categoriesreferencescontent_typesthroughcontent_type_id; hierarchical parent/child relation viaparent_id.
Observed DB columns (categories)
- id, content_type_id, parent_id, name, slug, description, image, is_active, sort_order, created_at, updated_at, deleted_at
Models verified
-
ContentType(app/Models/ContentType.php)- hasMany
categories()androotCategories() - uses
slugfor route binding - Status: OK and aligns with DB
- hasMany
-
Category(app/Models/Category.php)- belongsTo
contentType() - self-referential
parent()/children()(ordered bysort_order, thenname) descendants()recursive helperseo()relation,artworks()pivot- scopes:
active(),roots() - accessors:
full_slug_path,url,canonical_url,breadcrumbs - slug validation enforced in
boot()(lowercase; only a-z0-9- and dashes) - Status: OK and consistent with screenshots
- belongsTo
Key behaviors and checks
- URL formation:
$category->url->/{content_type.slug}/{category_path}; canonical URL ->https://skinbase.org{url} - Slug policy: generation with
Str::slug()+ model validation. Do not bypass. - Ordering: use
children()(sort_order then name) for deterministic menus. - Soft deletes: model uses
SoftDeletes; be explicit when you need trashed categories. - Eager-loading:
full_slug_pathwalks parents — eager-loadparent(or ancestors) to avoid N+1 when computing multiple paths.
Copilot / Dev rules (short checklist)
- Always look up content types by
slug, not by numeric ID. - Use
->roots()->active()->with('children')for public category lists. - Use
$category->urland$category->canonical_urlfor links and canonical tags. - Maintain slug rules: lowercase, only
a-z0-9-. - When reparenting categories, consider invalidating any cached derived paths for descendants.
- Avoid using legacy
artworks_categoriesdirectly in new controllers; create an adapter if you must read old data.
Suggested next steps
- Add a PHPUnit test asserting slug validation and
urlgeneration for nested categories. - (Optional) Generate a small ER diagram showing
content_types -> categories -> artwork_category.
Files referenced
If you want, I can now add the PHPUnit test or generate the ER diagram.