Appearance
HasPageConfigurableItems Trait
The HasPageConfigurableItems
trait extends the functionality of HasConfigurableItems
by adding specific configuration options for Filament Pages. This allows for centralized customization of page-specific properties through configuration files.
Features
This trait:
- Inherits all features from
HasConfigurableItems
- Adds configuration support for Filament Page-specific properties
- Maintains the same hierarchical configuration structure
Page-Specific Configurable Methods
The trait overrides the following page-specific methods to make them configurable:
shouldRegisterNavigation(): bool
Determines whether the page should appear in the navigation menu.
- Default: Inherits from parent class implementation
- Config Key:
shouldRegisterNavigation
getTitle(): string | Htmlable
Returns the title displayed in the browser tab.
- Default: Inherits from parent class implementation
- Config Key:
title
getHeading(): string | Htmlable
Returns the heading displayed at the top of the page.
- Default: Inherits from parent class implementation
- Config Key:
heading
Usage Example
Configuration File
php
// config/blog.php
return [
'dashboard_page' => [
'title' => 'Blog Dashboard',
'heading' => 'Blog Analytics',
'shouldRegisterNavigation' => true,
'navigationIcon' => 'heroicon-o-chart-bar',
'navigationGroup' => 'Blog',
'navigationSort' => 5,
],
];
Page Class
php
<?php
namespace Modules\Blog\Filament\Pages;
use Filament\Pages\Page;
use ModuleManager\ModuleManager\Concerns\HasPageConfigurableItems;
class DashboardPage extends Page
{
use HasPageConfigurableItems;
protected static ?string $slug = 'blog/dashboard';
// All navigation and display properties will be loaded from config
protected function getHeaderActions(): array
{
return [
// Your actions here
];
}
protected function getHeaderWidgets(): array
{
return [
// Your widgets here
];
}
}
Configuration Inheritance
The trait includes HasConfigurableItems
, which means it follows the same configuration lookup process:
- First in
module-manager.modules.[module_name].[class_name]
- Then in
[module_name].[class_name]
Notes
- This trait is specifically designed for use with Filament Pages
- It can significantly reduce boilerplate code in page classes
- It enables consistent theming and configuration across all pages in a module
- All configuration values can be overridden programmatically if needed