F
Filament15mo ago
Kleis

Hide widget on dashboard

I probably overlooked something simple, how can we hide a widget from the dashboard ? I made a stats widget for a page, but its not supposed to be shown on the dashboard aswell, but the dashboard ofcause shows all widgets in the widget folder so ...
7 Replies
Vp
Vp15mo ago
move your widgets to another folder
Kleis
KleisOP15mo ago
that was my initial idea too, but then its not found.
use App\Filament\PageWidgets\UsageOverview;
[...]
protected function getHeaderWidgets(): array
{
return [
UsageOverview::class
];
}
use App\Filament\PageWidgets\UsageOverview;
[...]
protected function getHeaderWidgets(): array
{
return [
UsageOverview::class
];
}
namespace App\Filament\PageWidgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Card;
use Illuminate\Support\Facades\DB;

class UsageOverview extends BaseWidget
namespace App\Filament\PageWidgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Card;
use Illuminate\Support\Facades\DB;

class UsageOverview extends BaseWidget
Unable to find component: [app.filament.page-widgets.usage-overview] I can hide it using canView and request matching, but its not pretty, since then the loading state of dashboard is wrong (I have executed composer dump-autoload), but it didnt help in locating the component
Kleis
KleisOP15mo ago
I have a custom dashboard (otherwise it would show the 2 default widgets), but it still renders all widgets from the widget folder
mark.cameron
mark.cameron12mo ago
@Kleis Ever figure this one out? Running into this issue as well... Can't move it out of app/Filament/Widgets or comment ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') in AdminPanelProvider...
awcodes
awcodes12mo ago
widgets are livewire components, so if it isn't autodiscovered you either have to put in it the livewire directory, register it manually in a service provider, or add it to the ->widgets() modifier on the panel.
Sigmoid
Sigmoid12mo ago
Here my solution: Inside your custom Dashboard page add the following function to override the autoload.
public function getWidgets(): array
{
// old autoload default widgets
// return Filament::getWidgets();
//new list of widgets to load
return [Widgets\StatsOverview::class];
}
public function getWidgets(): array
{
// old autoload default widgets
// return Filament::getWidgets();
//new list of widgets to load
return [Widgets\StatsOverview::class];
}
Want results from more Discord servers?
Add your server