multiple dashboards

i've read in the docs how to create multiple dashboards, but anytime I remove Dashboard::class from my pages() method as instructed, the navigation item disappears, and the next page in in my app just basically becomes the default. I've tried different things to try and make the dashboard show up without being in the pages method, but I haven't been able to. I've gone and looked at the Dashboard base class in the Filament directory and can't glean from that how exactly I should be making this work. It's not entirely clear from the docs (or I'm dumb) how exactly you can go about creating multiple dashboards.
->pages([
Dashboard::class,
])
->pages([
Dashboard::class,
])
5 Replies
Jon Mason
Jon MasonOP2mo ago
Would love it if there's an example repo where something like this is implemented so I could go poke around...it helps me to see examples rather than abstract descriptions.
awcodes
awcodes2mo ago
Sorry, don’t understand exactly what you are trying to accomplish. The dashboard is the default page for any panel. And the panel is defined by its panel provider class. So the only way to not have a dashboard class would be to ensure there are resources that build the navigation. And that can depend on policies too, so it’s more safe to always have a dashboard page so routing doesn’t break. Sounds like you might be forgetting about the auto registration for panel pages and resources. So it depends where the class is located in the app structure as to if it in needs to be manually added via pages() or not.
Jon Mason
Jon MasonOP2mo ago
ok, so I didn't do a good job explaining what I was trying to do, I was running into an issue with the first step, but didn't describe the end goal. I have a class I've been using for the dashboard. It needs to stay like a dashboard, but I need to move it, and have it not be the main page anymore, and I need to create a new dashboard. So I moved the old one to the pages directory and tried to make it extend the Page class, which I was able to do by adding a couple of methods., and copying the markup from the stock dashboard view. So I've almost got everything at this point, the old dashboard functions like I intend it to when I navigate to that page, but the new dashboard that's supposed to replace it as the true dashboard for the panel doesn't work. It's trying to access the widgets from the old dashboard. I feel like I've fixed all the references and anything that would cause it to do that. oh wait I just remembered about the discoverWidgets method...so I've gotta figure out how to make it not find the widgets for the old dashboard when you navigate to the new one.
toeknee
toeknee2mo ago
chekc the panel provider for where it searches automatically for widgets. The page rendered first is the first in the navigation simple.
Jon Mason
Jon MasonOP2mo ago
I switched everything back to where I have 2 pages that extend \Filament\Pages\Dashboard, and now i'm getting Route [filament.app.pages.dashboard] not defined.
->pages([
Dashboard::class,
MonthEndDashboard::class,
])
->pages([
Dashboard::class,
MonthEndDashboard::class,
])
ok I was able to fix that with: protected static string $routePath = '/'; in my MonthEndDashboard class. Now I'm getting a different error in my widget class...oof. I added a getWidgets method to each class so I could get the right widgets included on each dashboard. Now, despite having fully gutted my new Dashboard class, and having getWidgets() return an empty array, it's still returning the widget. it has to be something about this:
->discoverWidgets(in: app_path('Filament/App/Widgets'), for: 'App\\Filament\\App\\Widgets')
->widgets([
])
->discoverWidgets(in: app_path('Filament/App/Widgets'), for: 'App\\Filament\\App\\Widgets')
->widgets([
])
But I just get different errors if I remove any of that.. For some reason, this seems to fix the remaining issues: protected static ?string $navigationLabel = 'Month End Dashboard';
Want results from more Discord servers?
Add your server