diff --git a/src/Resources/NestedResource.php b/src/Resources/NestedResource.php index 6d20a4f..ea29195 100644 --- a/src/Resources/NestedResource.php +++ b/src/Resources/NestedResource.php @@ -62,18 +62,14 @@ public static function getBreadcrumbs(Page $page, ?Model $record = null): array } if ($ancestor) { - $index = $resource::hasPage('index') - ? [ - $resource::getUrl('index', [ - ...$ancestor->getNormalizedRouteParameters($record ?? $relatedRecord), - ]) => $resource::getBreadcrumb(), - ] - : [ - $ancestor->getResource()::getUrl('edit', [ - ...$ancestor->getNormalizedRouteParameters($record ?? $relatedRecord), - ]) . '#relation-manager' => $resource::getBreadcrumb(), - ]; + $ancestorResource = $ancestor->getResource(); + $urlParameters = $ancestor->getNormalizedRouteParameters($record ?? $relatedRecord); + $index = match (true) { + $resource::hasPage('index') => [$resource::getUrl('index', $urlParameters) => $resource::getBreadcrumb()], + $ancestorResource::hasPage('view') => [$ancestorResource::getUrl('view', $urlParameters) . '#relation-manager' => $resource::getBreadcrumb()], + default => [$ancestorResource::getUrl('edit', $urlParameters) . '#relation-manager' => $resource::getBreadcrumb()], + }; } else { $index = [$resource::getUrl('index') => $resource::getBreadcrumb()]; }