© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•17mo ago•
2 replies
Prodex

Weird override behavior

Hi, I'm overriding the Shield resource, so I don't have to publish the stubs. But I just don't understand why some methods can be overwritten but some others not.

For example: I can easierly overwrite shouldRegisterNavigation() or getNavigationLabel(), but I can't overwrite getPluralModelLabel().

Both getNavigationLabel() and getPluralModelLabel() are used the same way in the base Shield resource. But only getNavigationLabel() works, the other method (getPluralModelLabel) doesn't even get called.

Can someone explain to me, why this is happening?

Full code:
class ShieldOverrideResource extends RoleResource
{
    public static function getModelLabel(): string
    {
        return __('employee.permission_roles'); // doesn't work
    }

    public static function getPluralModelLabel(): string
    {
        return 'test'; // doesn't work
    }

    public static function getNavigationLabel(): string
    {
        return 'test'; // works
    }

    public static function getNavigationParentItem(): string
    {
        return __('employee.plural'); // works
    }

    public static function shouldRegisterNavigation(): bool
    {
        return true; // works
    }
}
class ShieldOverrideResource extends RoleResource
{
    public static function getModelLabel(): string
    {
        return __('employee.permission_roles'); // doesn't work
    }

    public static function getPluralModelLabel(): string
    {
        return 'test'; // doesn't work
    }

    public static function getNavigationLabel(): string
    {
        return 'test'; // works
    }

    public static function getNavigationParentItem(): string
    {
        return __('employee.plural'); // works
    }

    public static function shouldRegisterNavigation(): bool
    {
        return true; // works
    }
}


For reference, this is the shield base class resource:
    public static function getPluralModelLabel(): string
    {
        return __('filament-shield::filament-shield.resource.label.roles');
    }

    public static function getNavigationLabel(): string
    {
        return __('filament-shield::filament-shield.nav.role.label');
    }
    public static function getPluralModelLabel(): string
    {
        return __('filament-shield::filament-shield.resource.label.roles');
    }

    public static function getNavigationLabel(): string
    {
        return __('filament-shield::filament-shield.nav.role.label');
    }
Solution
The reason some method overrides work while others don’t is due to how they are scoped and utilized. For example, model label and model plural label overrides do not work because you’re only overriding the
RoleResource
RoleResource
. To make those overrides work, you also need to extend the
ListRoles
ListRoles
page of the resource and bind your custom implementation in a service provider, just like you did with the resource.

The same applies to sub-navigation. To get sub-navigation working, you need to extend both the
EditRole
EditRole
and
ViewRole
ViewRole
pages of the
RoleResource
RoleResource
with your custom implementation of those pages. Once you’ve done that, bind them in a service provider. Then, within your custom
RoleResource
RoleResource
(
ShieldOverrideResource
ShieldOverrideResource
) implementation, override the
getPages()
getPages()
method to provide your implementation for those pages, and implement
getRecordSubNavigation()
getRecordSubNavigation()
accordingly.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Weird behavior when creating resource
FilamentFFilament / ❓┊help
2y ago
TextInput afterStateUpdated() reactive weird behavior
FilamentFFilament / ❓┊help
3y ago
Customize or override default behavior of page title
FilamentFFilament / ❓┊help
2y ago
Weird behavior in nested repeater relationship
FilamentFFilament / ❓┊help
12mo ago