Skip to content

小组件 Widgets

添加过滤参数 tableFilters

生成URL时添加过滤条件。

php
Stat::make('Open Issues', $openIssuesCount)
    ->url(ListUsers::getUrl([
        'tableFilters' => [ 
            'status' => [ 
                'value' => 'open', 
            ] 
        ] 
    ]))->description("There are {$openIssuesCount} open issues"),
php
use App\Filament\Widgets\StatsOverview;

return $panel->widgets([
    StatsOverview::class, 
    Widgets\AccountWidget::class,
    Widgets\FilamentInfoWidget::class,
])
php
use App\Filament\Widgets\StatsOverview;

protected function getHeaderWidgets(): array
{
    return [
        StatsOverview::class, 
    ];
}

此时,在对应的资源类上添加对应的过滤器。

php
// IssueResource.php

$table
    // ...
    ->filters([
        SelectFilter::make('status') 
            ->options(IssueStatus::class), 
    ])