F
Filament10mo ago
TK

Setting navigation group as collapsed by default

How do I set a navigation group, which is created from the resource AND used by multiple resources, to be collapsed by default?
class RelationFilamentResource extends Resource
{
...

public static function getNavigationLabel(): string
{
return 'Relations';
}

public static function getNavigationGroup(): ?string
{
return 'Reservations'; // <--- same navigation group that should be collapsed by default!
}

...
class RelationFilamentResource extends Resource
{
...

public static function getNavigationLabel(): string
{
return 'Relations';
}

public static function getNavigationGroup(): ?string
{
return 'Reservations'; // <--- same navigation group that should be collapsed by default!
}

...
class PaymentFilamentResource extends Resource
{
...

public static function getNavigationLabel(): string
{
return 'Payments';
}

public static function getNavigationGroup(): ?string
{
return 'Reservations'; // <--- same navigation group that should be collapsed by default!
}

...
class PaymentFilamentResource extends Resource
{
...

public static function getNavigationLabel(): string
{
return 'Payments';
}

public static function getNavigationGroup(): ?string
{
return 'Reservations'; // <--- same navigation group that should be collapsed by default!
}

...
4 Replies
Expecto Patronum
Expecto Patronum10mo ago
you can set navigation group in your panel provider and set the group every each resources that you wish. you can refer to this documentation. and add ->collapsed()
No description
TK
TKOP10mo ago
@Expecto Patronum I've tried that, but nothing changed. Just to make sure I understand, I DEFINE the navigation groups inside the panel provider, and remove the navigation group definitions in the resources. I only tell the resources under which navigation group they should belong? For some reason, I can't get this to work. What change do I need to make in the resources? Also, whatever group I make via the portal provider, they aren't showing up. Got it working.. Appearently it only works, if you actually apply a resource to that menu "name" ty!
Expecto Patronum
Expecto Patronum10mo ago
Yes Glad to hear it
nighty
nighty6mo ago
Hello, i have to ask again ... i have a similar problem and want to collapse some NavigationGroups on loading ... in my case if i add ->collapsed() nothing changed, i am also using only a AdminPanelProvider for Navigation generation. i checked the NavigationItems with dd() and they get the corret settings - for me, it seems if the are feed back into the builder instance, this setting get completely lost. foreach($arrNavGroup as $group){ $group->collapsible(true)->collapsed(true); #dd($group); //collapsible is applied $builder->group($group); } return $builder; //collapsible flag gone after return any hint on this? thanks for any hint guys i dont understand what you have done .... could you please explain a bit more? thanks maybe one more thing to mention .... i calll the obove code in $panel->navigation(function (NavigationBuilder $builder): NavigationBuilder {}

Did you find this page helpful?