Skip to content

fix(images): resolve nested definitions and versions through their relations - #178

Open
ericwang401 wants to merge 1 commit into
integration/v5-workstreamsfrom
fix/image-definition-bindings
Open

ericwang401 wants to merge 1 commit into
integration/v5-workstreamsfrom
fix/image-definition-bindings

Conversation

@ericwang401

@ericwang401 ericwang401 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Every admin route under /image-groups/{group}/images/{definition} answered 500:

Call to undefined method App\Models\ImageGroup::imageDefinitions()

The admin API is registered with scopeBindings(), which resolves a child route parameter through a parent relation named after it. {image_definition} under {image_group} therefore goes through ImageGroup::imageDefinitions(), and {image_version} under {image_definition} through ImageDefinition::imageVersions(). Neither exists; the relations are definitions() and versions(). This broke the image card's Versions dialog (the version list and Publish version), image Edit, and the definition/version endpoints on /api/application.

Fix

ImageGroup and ImageDefinition override childRouteBindingRelationshipName() to map those two parameters onto the existing relations. The routes, their parameter names and the Wayfinder keys the frontend uses are unchanged, and so is scoping: a child requested under the wrong parent still 404s.

Tests

tests/Feature/Images/ImageRouteBindingTest.php covers the routes over HTTP. Nothing did before, which is how this got through:

  • a definition is shown through its group
  • versions are listed and shown through their definition
  • a definition under another group, and a version under another definition, 404

All four fail without the model change (the 404 cases 500). The full Pest suite passes (1149 tests), and pint and phpstan are clean.

The Playwright suite in #179 found this, and its catalogue specs now read definitions and versions through these routes.

…lations

The admin API is registered with scopeBindings(), which resolves a child
route parameter through a parent relation named after it: `{image_definition}`
under `{image_group}` through ImageGroup::imageDefinitions(), and
`{image_version}` under `{image_definition}` through
ImageDefinition::imageVersions(). Neither exists -- the relations are
definitions() and versions() -- so every route below
/image-groups/{group}/images/{definition} answered 500, taking the Versions
dialog, image edit and version publishing with it.

Map those two parameters onto the existing relations, and cover the routes
over HTTP, including a child requested under the wrong parent still 404ing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant