© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago
Abdellah Belkaid

Rendering widgets on multiple dashboard

Hi everyone,

I'm working on a Filament project with two separate dashboard pages under the same admin panel:

/admin/dashboard
/admin/dashboard
for general dashboard widgets
/admin/statistics
/admin/statistics
for statistics-related widgets
I want to conditionally render widgets on these pages using the canView() method.
My logic checks the current URL and displays the widgets only on their respective pages.
Here’s how I handle it:

public static function canView(): bool
{
    if (request()->is('admin/dashboard')) {
        return true;
    }
    return false;
}
public static function canView(): bool
{
    if (request()->is('admin/dashboard')) {
        return true;
    }
    return false;
}

However, I'm running into a problem with the URL when applying filters. For example, when filtering on /admin/statistics, the URL becomes something like this:


http://127.0.0.1:8000/admin/statistics?filters[period]=today&filters[startDate]=2024-10-24
http://127.0.0.1:8000/admin/statistics?filters[period]=today&filters[startDate]=2024-10-24

In this case, the canView() logic behaves unexpectedly, and widgets for the statistics page get hidden while dashboard widgets show up, likely because of the filters in the URL.

What I've Tried
I modified the canView() method to check for specific URLs using request()->url() and request()->is() but the issue persists when filters are applied.
I also tried using variables inside the widget and passing them to canView(), but I ran into the issue of using non-static variables inside a static method.

is there a way to render the widgets directly from the page itself like Dashboard or Statistics
    protected function getHeaderWidgets(): array
    {
        return [
            GlobalStatistics::class,
                // NewUsersTable::class,
            CompanyRevenuesDoughnutchart::class,
        ];
    }
    protected function getHeaderWidgets(): array
    {
        return [
            GlobalStatistics::class,
                // NewUsersTable::class,
            CompanyRevenuesDoughnutchart::class,
        ];
    }

but it doesn't work
Is there a better way to handle this scenario where widgets are shown/hidden correctly based on both the URL and the applied filters?
Thanks 🌹
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

Widgets on Multiple Dashboards
FilamentFFilament / ❓┊help
2y ago
Multiple identical widgets on dashboard
FilamentFFilament / ❓┊help
2y ago
Ordering Widgets On dashboard
FilamentFFilament / ❓┊help
2y ago
Dashboard widgets
FilamentFFilament / ❓┊help
12mo ago