How to add a secondary dashboard to Filament
FilamentTo get a new dashboard with widgets on Filament, there are a few steps to get going:
- Create a new `Dashboard.php` file in Pages.
- Remove the old dashboard class file in `AdminPanelProvider.php` file.
- Ensure you have the correct widgets specified in getWidgets() for the old and new dashboard, e.g.:
class LicenseDashboard extends \Filament\Pages\Dashboard
{
protected static string $routePath = 'licenses';
protected static ?string $title = 'Licenses';
protected static ?int $navigationSort = 11;
protected static ?string $navigationGroup = 'System';
protected static ?string $navigationIcon = 'heroicon-o-star';
function getWidgets(): array
{
return [
LicensesOverview::class,
];
}
public static function canAccess(): bool
{
return auth()->user()->role==Role::SuperAdmin;
}
}
lang-phpAs you can see, to further limit the dashboard on a multi-tenancy system we also use `canAccess()` to check the role.