F
Filament3mo ago
John

Moving route registration removes theme css styling

I want to dynamically determine resource pages. Old setup works:
// app/Filament/Resources/RequestResource.php
public static function getPages(): array
{
return array_filter([
'index' => ListRequests::route('/'),
'create' => CreateRequest::route('/create'),
'edit' => RequestWorkflow::route('/{record:uuid}/edit'),
'stats' => RequestStats::route('/stats'),
]);
}
// app/Filament/Resources/RequestResource.php
public static function getPages(): array
{
return array_filter([
'index' => ListRequests::route('/'),
'create' => CreateRequest::route('/create'),
'edit' => RequestWorkflow::route('/{record:uuid}/edit'),
'stats' => RequestStats::route('/stats'),
]);
}
But when I remove the 'stats' line, and add this:
// routes/web.php
Route::get('requests/stats', RequestStats::class)->name('filament.resources.requests.stats');
// routes/web.php
Route::get('requests/stats', RequestStats::class)->name('filament.resources.requests.stats');
the page still loads, but the Filament theme styling is gone. - No console errors - No laravel errors - Livewire still works fine - route::list gives same result for the stats route, before and after the change - Custom theme styling gone - Also, Vite stops hot reloading Any help is appreciated.
2 Replies
LeandroFerreira
LeandroFerreira3mo ago
Why would you like to add this in the web.php?
John
John3mo ago
Ultimately I want to register routes depending on the current tenant. So next step is tenantConfig()->registerRoutes() which is a helper to get current tenant. But even directly in web.php fails. After some more investigation: Every request hits Filament::registerViteTheme() in service provider. Also the broken theme request. But; the broken page only loads /filament/assets/app.css?id=ceb9a486dfc44ebe8adaa3bd510821e8 in network tab. While all other pages load http://[::1]:5173/resources/css/filament.css (and a bunch of custom stuff I put in the service provider). I've restarted npm run dev and run artisan optimize:clear Any clue? Is there something magic about getPages() that makes custom styling work? I'm still stumped...