66 lines
2.0 KiB
PHP
66 lines
2.0 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'),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
}
|