Admin Panel Provider
The Admin Panel Provider configures the administrative backend interface using FilamentPHP. It establishes authentication mechanisms, visual components, middleware configurations, and plugin integrations for administrative users.
Configuration Breakdown
Basic Panel Settings
->default()
->id('admin')
->path('admin')
default()
: Sets this as the default panel for the applicationid('admin')
: Assigns a unique identifier to the panelpath('admin')
: Determines the URL path for accessing the admin panel (e.g.,example.com/admin
)
Authentication Features
->login()
->passwordReset()
->emailVerification()
->profile()
login()
: Enables the login page for administratorspasswordReset()
: Adds password reset functionalityemailVerification()
: Implements email verification for new admin accountsprofile()
: Provides user profile management capabilities
Branding Configuration
->favicon(asset('images/favicon.ico'))
->brandLogo(asset('images/logo-light.svg'))
->darkModeBrandLogo(asset('images/logo-dark.svg'))
->brandLogoHeight('2rem')
favicon()
: Sets the browser tab iconbrandLogo()
: Defines the logo displayed in light modedarkModeBrandLogo()
: Specifies an alternative logo for dark modebrandLogoHeight()
: Controls the displayed logo height
User Experience Enhancements
->colors([
'primary' => Color::Blue,
])
->unsavedChangesAlerts()
->spa()
->sidebarCollapsibleOnDesktop()
->maxContentWidth(MaxWidth::Full)
colors()
: Defines the color scheme with blue as the primary colorunsavedChangesAlerts()
: Warns users when trying to navigate away with unsaved changesspa()
: Enables Single Page Application mode for smoother transitionssidebarCollapsibleOnDesktop()
: Makes the sidebar collapsible on desktop devicesmaxContentWidth()
: Sets content width to full screen
Navigation Structure
->navigationGroups([
NavigationGroup::make()->label('Dashboard'),
NavigationGroup::make()->label('Settings'),
])
- Creates two main navigation groups: Dashboard and Settings
- Groups help organize navigation items into logical sections
Plugin Integration
->plugins([
FilamentShieldPlugin::make()
->gridColumns([
'default' => 1,
'sm' => 1,
'lg' => 2,
'xl' => 3,
])
->sectionColumnSpan(1)
->checkboxListColumns([
'default' => 1,
'sm' => 1,
'lg' => 2,
'xl' => 3,
])
->resourceCheckboxListColumns([
'default' => 1,
'sm' => 2,
]),
PluginManager::make(),
])
FilamentShieldPlugin
: Implements role-based permissions with responsive layouts for different screen sizesgridColumns()
: Configures the responsive column layout for permissions gridsectionColumnSpan()
: Defines how many columns a section should spancheckboxListColumns()
: Sets responsive columns for checkbox listsresourceCheckboxListColumns()
: Controls columns for resource permission checkboxes
PluginManager::make()
: Initializes the custom plugin manager (detailed below)
above panel's plugins array you can define own custom plugin, you can use any third party plugin here.
Middleware Configuration
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
])
middleware()
: Registers middleware that executes on all panel routes:- Cookie encryption and management
- Session handling
- CSRF protection
- Route model binding
- Filament-specific middleware
authMiddleware()
: Applies only to authenticated routes, ensuring users are properly logged in
Customer Panel Provider
The Customer Panel Provider configures the frontend interface for customers, offering a streamlined experience with customer-specific authentication and features.
Configuration Breakdown
Basic Panel Settings
->id('customer')
->path('/')
->homeUrl('/')
id('customer')
: Assigns a unique 'customer' identifierpath('/')
: Sets the panel at the root URL pathhomeUrl('/')
: Defines the home page URL
Authentication Features
->login()
->authPasswordBroker('customers')
->passwordReset()
->registration()
->profile(isSimple: false)
login()
: Enables customer login functionalityauthPasswordBroker('customers')
: Specifies the password broker for customer authenticationpasswordReset()
: Adds password reset capabilitiesregistration()
: Enables self-registration for customersprofile(isSimple: false)
: Implements a full-featured profile management system
Branding Configuration
->favicon(asset('images/favicon.ico'))
->brandLogo(asset('images/logo-light.svg'))
->darkMode(false)
->brandLogoHeight('2rem')
favicon()
: Sets the browser tab iconbrandLogo()
: Defines the customer panel logodarkMode(false)
: Disables dark mode for customers by defaultbrandLogoHeight()
: Controls the displayed logo height
UI and Navigation
->colors([
'primary' => Color::Blue,
])
->topNavigation()
colors()
: Sets blue as the primary color themetopNavigation()
: Implements a horizontal navigation bar at the top of the page
Plugin Integration
->plugins([
PluginManager::make(),
])
- Initializes the custom plugin manager to load all registered plugins
Middleware and Authentication
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authGuard('customer')
- Registers essential middleware similar to the admin panel
authGuard('customer')
: Specifies the 'customer' guard for authentication, ensuring customers only access customer-specific features
Custom Plugin Manager
The Plugin Manager facilitates modular functionality by dynamically loading and registering plugins from across the application.
Code Analysis
namespace Webkul\Support;
use Filament\Contracts\Plugin;
use Filament\Panel;
use function Illuminate\Filesystem\join_paths;
class PluginManager implements Plugin
{
public function getId(): string
{
return 'plugin-manager';
}
- Implements Filament's
Plugin
contract getId()
: Returns a unique identifier for the plugin manager
public function register(Panel $panel): void
{
$plugins = $this->getPlugins();
foreach ($plugins as $modulePlugin) {
$panel->plugin($modulePlugin::make());
}
}
register()
: Core method that:- Retrieves all available plugins using
getPlugins()
- Iterates through each plugin class
- Instantiates each plugin via its static
make()
method - Registers each plugin with the panel
- Retrieves all available plugins using
public function boot(Panel $panel): void {}
public static function make(): static
{
return app(static::class);
}
public static function get(): static
{
/** @var static $plugin */
$plugin = filament(app(static::class)->getId());
return $plugin;
}
boot()
: Empty implementation as no special bootstrapping is neededmake()
: Static factory method that returns a new instance from the service containerget()
: Retrieves the plugin instance that's registered with Filament
protected function getPlugins(): array
{
$plugins = require join_paths(base_path().'/bootstrap', 'plugins.php');
$plugins = collect($plugins)
->unique()
->sort()
->values()
->toArray();
return $plugins;
}
}
getPlugins()
: Loads plugin definitions from a configuration file:- Requires the
plugins.php
file from the bootstrap directory - Converts the array to a collection
- Ensures entries are unique and sorted
- Returns the final array of plugin class names
- Requires the
Plugin Registration Process
- The system loads
plugins.php
from the bootstrap directory containing an array of plugin class names - The PluginManager removes duplicates and sorts the list
- Each plugin is instantiated via its
make()
method - Filament registers each plugin with the panel
This allows modular functionality to be added to both admin and customer panels without modifying core code.
Key Benefits
- Separation of Concerns: Admin and customer interfaces are cleanly separated
- Modular Design: The Plugin Manager enables extending functionality without core modifications
- Security: Different authentication guards ensure proper access control
- Responsive Design: Layout adjustments for different screen sizes
- Enhanced UX: Features like SPA mode and unsaved changes alerts improve user experience
Integration Example
To add a new plugin to the system:
- Create a plugin class implementing Filament's Plugin contract
- Add the fully qualified class name to
bootstrap/plugins.php
- The PluginManager will automatically load and register it
This architecture enables seamless extension of the Aureus ERP system with new modules and functionality.