- 8 个资源表格 recordUrl(null)+recordAction(null):行不再可点击,查看/编辑仅通过操作列按钮;标题列不再自动变链接 - 标题列单行省略(含分类描述),长标题不换行,所有数据行统一 53px 与表头等高 - 筛选下拉控件紧凑(min-height 1.75rem、字号 0.8rem),与应用按钮协调 - 重置链接紧跟应用筛选按钮(不再推到最右) - 操作列固定宽度 88px - 实测:表头=数据行=53px、行点击关闭、重置紧跟应用
68 lines
2.2 KiB
PHP
68 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace App\Filament\Resources\Users\Tables;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class UsersTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name')
|
|
->label('昵称')
|
|
->searchable()
|
|
->weight('bold'),
|
|
TextColumn::make('email')
|
|
->label('邮箱')
|
|
->searchable(),
|
|
TextColumn::make('roles.name')
|
|
->label('角色')
|
|
->badge()
|
|
->formatStateUsing(fn ($state) => match ($state) {
|
|
'admin' => '管理组',
|
|
'editor' => '撰写组',
|
|
'member' => '会员',
|
|
default => $state,
|
|
}),
|
|
TextColumn::make('posts_count')
|
|
->label('文章')
|
|
->counts('posts')
|
|
->sortable(),
|
|
TextColumn::make('logincount')
|
|
->label('登录次数')
|
|
->sortable(),
|
|
TextColumn::make('loginip')
|
|
->label('最近 IP'),
|
|
TextColumn::make('created_at')
|
|
->label('注册时间')
|
|
->dateTime('Y-m-d')
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
\Filament\Tables\Filters\SelectFilter::make('roles')
|
|
->label('角色')
|
|
->relationship('roles', 'name'),
|
|
], \Filament\Tables\Enums\FiltersLayout::AboveContent)
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->recordUrl(null)
|
|
->recordAction(null)
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
}
|