Navigation Items between Navigation groups

return $builder
->groups([
NavigationGroup::make('Test 1')
->items([
...RoleResource::getNavigationItems(),
]),
])
->items([
...ConstructionSiteResource::getNavigationItems(),
])
->groups([
NavigationGroup::make('Test')
->items([
...UserAdminResource::getNavigationItems(),
...UserCustomerResource::getNavigationItems(),
]),
]);
return $builder
->groups([
NavigationGroup::make('Test 1')
->items([
...RoleResource::getNavigationItems(),
]),
])
->items([
...ConstructionSiteResource::getNavigationItems(),
])
->groups([
NavigationGroup::make('Test')
->items([
...UserAdminResource::getNavigationItems(),
...UserCustomerResource::getNavigationItems(),
]),
]);
` This code place my constructionSite item at the top, not in the middle.
No description
6 Replies
Hasnayeen
Hasnayeen16mo ago
use custom navigation builder
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder->groups([
NavigationGroup::make('Shop')
->items([
...ProductResource::getNavigationItems(),
]),
NavigationGroup::make('')
->items([
NavigationItem::make('Dashboard')
->icon('heroicon-o-home')
->isActiveWhen(fn (): bool => request()->routeIs('filament.admin.pages.dashboard'))
->url(fn (): string => Dashboard::getUrl()),
]),
NavigationGroup::make('Blog')
->items([
...PostResource::getNavigationItems(),
]),
]);
})
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder->groups([
NavigationGroup::make('Shop')
->items([
...ProductResource::getNavigationItems(),
]),
NavigationGroup::make('')
->items([
NavigationItem::make('Dashboard')
->icon('heroicon-o-home')
->isActiveWhen(fn (): bool => request()->routeIs('filament.admin.pages.dashboard'))
->url(fn (): string => Dashboard::getUrl()),
]),
NavigationGroup::make('Blog')
->items([
...PostResource::getNavigationItems(),
]),
]);
})
zoomZoom
zoomZoomOP16mo ago
You rock ! Thank you very very much !
SinthuMS
SinthuMS13mo ago
Call to a member function getUrl() on array i get this error while using custom navigation builder please help
DrByte
DrByte13mo ago
Please start a new #❓┊help post for this, including your code.
SinthuMS
SinthuMS13mo ago
Oh thanks
binaryfire
binaryfire13mo ago
I don't think using policies to hide resource links works with this solution? Eg. if you do this:
NavigationGroup::make('Blog')
->items([
...PostResource::getNavigationItems(),
]),
NavigationGroup::make('Blog')
->items([
...PostResource::getNavigationItems(),
]),
the post resource nav item and "Blog" group will always be visible regardless of policy settings. Does anyone know of a workaround other than manually creating a NavigationItem for every resource?

Did you find this page helpful?