Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Alphy Gacheru's avatar

How to conditionally render the deafult Admin navigation link in Filament PHP?

0

With filament PHP, I have a 'Dashboard' navigation link that loads '/admin' URL in the browser. I want to render the navigation link conditionally. How can I do this?

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

You can override the shouldRegisterNavigation method on the Page class - to achieve this, you will need to make your own Dashboard class that extends the base Dashboard from the vendor directory.

https://filamentphp.com/docs/3.x/panels/navigation#disabling-resource-or-page-navigation-items

Similarly, you will need to implement a canAccess method to authorize the user to visit the page - since the shouldRegisterNavigation method only determines if it is in the menu.

Alphy Gacheru's avatar

@tykus If I understood you correctly, should it be like this?

<?php

namespace App\Filament\Pages;

class Dashboard extends \Filament\Pages\Dashboard
{
    public static function shouldRegisterNavigation(): bool
    {
        return false;
    }
}
tykus's avatar

@Alphy Gacheru yes, but you also need to tell Filament not to use their Dashboard; instead to discovery yours. You can comment this line in the PanelProvider class.

->pages([
    // Pages\Dashboard::class,
])
1 like

Please or to participate in this conversation.