Implement Collection parent-child hierarchy management; fix broken item image URLs (#636)

Commit: 0848c1984eb9fcb49399bf250b46beeb204a0b2a
Date: 2026-03-22 19:03:22 +0100
Author: Copilot

Commit Message

Implement Collection parent-child hierarchy management; fix broken item image URLs (#636)

* Initial plan

* Implement parent-child hierarchy for Collections; fix broken image URLs

Co-authored-by: metanull <20630081+metanull@users.noreply.github.com>
Agent-Logs-Url: https://github.com/metanull/inventory-app/sessions/f798c719-8fc6-412f-8a98-b1724c217ba2

* Fix: lint & format

* Fix: Blade/Livewire frontend app for Collection/Item hierarchies

**Collection Hierarchy:**
- CollectionsTable.php: Added `parentId`, `hierarchyMode`, breadcrumbs computed property, `navigateToParent()`, `navigateUp()`, `toggleHierarchyMode()` methods, and hierarchy filtering with `withCount('children')`
- collections-table.blade.php: Added breadcrumb trail, hierarchy/flat toggle button, children count column, drill-down chevron on rows with children, and back button
- CollectionsTableTest.php: 9 tests covering rendering, root filtering, navigation, flat mode, breadcrumbs, children count, search, toggle reset, and multi-level breadcrumbs

**Item Hierarchy:**
- ItemsTable.php: Same hierarchy pattern using `parents()` scope, `withCount('children')`, breadcrumbs, and navigation methods
- items-table.blade.php: Same UI pattern as collections with teal entity color
- ItemsTableTest.php: 11 tests including type filter and tag filter compatibility with hierarchy mode

* Fix: Item/Collection parent-child breadcrumb

**`show-page-v2` layout** — Added an optional `breadcrumbs` array prop. When provided, ancestor links render after "← Back to list" separated by `/`:

← Back to list / Grandparent / Parent

Each ancestor is a clickable link styled with the entity's accent color. Root-level records show only "← Back to list" as before (backward compatible).

**Controllers** — Both CollectionController and ItemController build the ancestor chain in a private `buildAncestorBreadcrumbs()` method that walks the `parent` relationship and returns an array of `['label' => ..., 'url' => ...]`.

**Show views** — Both collections/show.blade.php and items/show.blade.php pass `:breadcrumbs="$breadcrumbs"` to the layout component.

**Tests** — 4 new tests across CollectionParentChildTest and ItemParentChildTest verifying breadcrumb rendering for nested records and absence for root records. All 1480 tests pass.

* Fix: Collection Items navigation

 **New route:** `GET /web/collections/{collection}/items/{item}` → `collections.items.show`

**Controller:** `CollectionController::showItem()` builds a combined breadcrumb chain: collection ancestors → the collection itself → item ancestors. It reuses the same `items/show.blade.php` view, passing a `$collection` variable.

**Views updated:**
- collection-items-section.blade.php — item links now use `collections.items.show`
- items/show.blade.php — `backRoute` points to `collections.index` when `$collection` is set; passes `$collection` to sidebar cards
- parent-item-card, children-items-card, item-relationship-card, links-card — all accept optional `$collection` prop and use collection-scoped routes for item links when set

**Breadcrumb example:** For Collection 1 → Collection 2 → Item A → Item B:

← Back to list / Collection 1 / Collection 2 / Item A


**Tests:** 6 new tests in CollectionItemTest.php covering the nested route rendering, breadcrumbs with collection ancestors, item ancestors within collection context, authentication, and link generation. All 1485 tests pass.

* 6.12.3

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: metanull <20630081+metanull@users.noreply.github.com>
Co-authored-by: Pascal HAVELANGE <havelangep@hotmail.com>

Files Changed


This documentation was automatically generated from Git commit data.