© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago•
2 replies
NLD_Brian

Adding navigationitems dynamically

I'm trying to achieve the following:

We have divisions within our company,
Each division has their own lease and car management, so therefor when we open the Divisions & Cars group, it will contain a couple other navigation groups (depending on how many divisions, and the title gets fetched from the database(divisions->name).

Each of the division group contains the Lease and Car management, and when we open these, you'll be shown the resource but only get the results that belong to that certain division.

I'm trying to figure out how to map out the navigation for this to work, all i got up to is this, and since i'm still fairly new to all this, i figured it might be better to ask for some help

->navigation(function (NavigationBuilder $builder): NavigationBuilder {
                return $builder->groups([
                    NavigationGroup::make('Divisions & Cars')
                        ->items(
                            Division::all()->map(function ($division) {
                                return NavigationGroup::make($division->name)
                                    ->items([
                                        NavigationItem::make('Car Management')
                                            ->url('/fleet-management?division_id=' . $division->id),
                                    ]);
                            })->toArray()
                        ),
                ]);
            })
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
                return $builder->groups([
                    NavigationGroup::make('Divisions & Cars')
                        ->items(
                            Division::all()->map(function ($division) {
                                return NavigationGroup::make($division->name)
                                    ->items([
                                        NavigationItem::make('Car Management')
                                            ->url('/fleet-management?division_id=' . $division->id),
                                    ]);
                            })->toArray()
                        ),
                ]);
            })
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

navigationitems override
FilamentFFilament / ❓┊help
2y ago
Call auth()->user() from NavigationItems
FilamentFFilament / ❓┊help
3y ago
Can we modify SpatieTags to prevent dynamically adding new tags?
FilamentFFilament / ❓┊help
2y ago
Dynamically translate labels using configureUsing by adding a new translatable label
FilamentFFilament / ❓┊help
3y ago