F
Filament2mo ago
ahmant

Collapse list page widgets

I want to be able to collapse (show/hide) the widgets above the table. How to do that? I have these widgets in my resource list page
public static function getWidgets(): array
{
return [
OrderStats::class,
];
}
public static function getWidgets(): array
{
return [
OrderStats::class,
];
}
<?php

namespace App\Filament\Resources\OrderResource\Widgets;

use App\Filament\Resources\OrderResource\Pages\ListOrders;
use Filament\Widgets\Concerns\InteractsWithPageTable;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class OrderStats extends BaseWidget
{
use InteractsWithPageTable;

protected static ?string $pollingInterval = null;

protected function getTablePage(): string
{
return ListOrders::class;
}

protected function getStats(): array
{
return [
Stat::make(__("general.orders"), $this->getPageTableQuery()->count()),
Stat::make(__("general.passengers"), $this->getPageTableQuery()->sum('passengers_number')),
];
}
}
<?php

namespace App\Filament\Resources\OrderResource\Widgets;

use App\Filament\Resources\OrderResource\Pages\ListOrders;
use Filament\Widgets\Concerns\InteractsWithPageTable;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class OrderStats extends BaseWidget
{
use InteractsWithPageTable;

protected static ?string $pollingInterval = null;

protected function getTablePage(): string
{
return ListOrders::class;
}

protected function getStats(): array
{
return [
Stat::make(__("general.orders"), $this->getPageTableQuery()->count()),
Stat::make(__("general.passengers"), $this->getPageTableQuery()->sum('passengers_number')),
];
}
}
No description
5 Replies
ahmant
ahmant2mo ago
Any one can help?
awcodes
awcodes2mo ago
Do you want to collapse them individually or as a group? Either way you’ll need a custom widget so you can update the views.
ahmant
ahmant2mo ago
I want to collapse them in group. Can you tell me which view should I update? Or if I need to create a custom widget, can we create a widget that will contains other widgets? I read these pages: - https://filamentphp.com/docs/3.x/panels/resources/widgets#creating-a-resource-widget - https://filamentphp.com/docs/3.x/support/plugins/build-a-panel-plugin#step-4-create-the-widget But I didn't find a way to da that
awcodes
awcodes2mo ago
Yea. You’ll need a custom widget with a custom view. Widgets are just livewire components.
ahmant
ahmant2mo ago
Ok then, I will create a custom one, and let you know the results
Want results from more Discord servers?
Add your server
More Posts