How do we overwrite all resource pages?

I'm trying to change how the heading works across all pages without editing them all. Tried using macro but this doesn't get called. Also tried aliasing the BasePage class. Is there another way?
\Filament\Pages\BasePage::macro('getHeading', function (): string|Htmlable {
return 'Test Heading';
});
\Filament\Pages\BasePage::macro('getHeading', function (): string|Htmlable {
return 'Test Heading';
});
4 Replies
WyreZ
WyreZ6mo ago
In your main panel on AdminPanelProvider.php you might need to set ->brandName('Your Global Page Title') Is that what you mean? If this is the same issue that I had, the docs were very hard to find a good answer for this.
gizmojo
gizmojoOP6mo ago
awcodes
awcodes6mo ago
You will probably have to extend the Edit and Create Record classes. I’m not sure that macros work to override existing methods. I could be wrong though.
Chrispian
Chrispian6mo ago
I don't think marcos work like this. I would use a trait if it's something this common. You would still need to add it to each resource but you could probably modify the stubs for filament. Also, here's a nice little trick from @Zep Fietje to go along with it. https://x.com/zepfietje/status/1798660116020965810
Zep Fietje (@zepfietje) on X
Came up with a neat way of reusing @filamentphp render hooks. 💡 Instead of registering the hook in a service provider for given scopes, I moved it to the boot method of a trait. Now any page that uses the HasFooterActions trait will automatically render the footer actions. 👌
From An unknown user
Twitter
Want results from more Discord servers?
Add your server