|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Filament\Resources\Users\Tables; |
| 4 | + |
| 5 | +use Filament\Actions\ViewAction; |
| 6 | +use Filament\Tables\Columns\TextColumn; |
| 7 | +use Filament\Tables\Enums\FiltersLayout; |
| 8 | +use Filament\Tables\Filters\SelectFilter; |
| 9 | +use Filament\Tables\Table; |
| 10 | + |
| 11 | +class UsersTable |
| 12 | +{ |
| 13 | + public static function configure(Table $table): Table |
| 14 | + { |
| 15 | + return $table |
| 16 | + ->columns([ |
| 17 | + TextColumn::make('name') |
| 18 | + ->searchable() |
| 19 | + ->toggleable(), |
| 20 | + TextColumn::make('email') |
| 21 | + ->label('Email address') |
| 22 | + ->searchable() |
| 23 | + ->toggleable(), |
| 24 | + TextColumn::make('email_verified_at') |
| 25 | + ->dateTime() |
| 26 | + ->sortable() |
| 27 | + ->toggleable(), |
| 28 | + TextColumn::make('created_at') |
| 29 | + ->dateTime() |
| 30 | + ->sortable() |
| 31 | + ->toggleable(isToggledHiddenByDefault: true), |
| 32 | + TextColumn::make('updated_at') |
| 33 | + ->dateTime() |
| 34 | + ->sortable() |
| 35 | + ->toggleable(isToggledHiddenByDefault: true), |
| 36 | + ]) |
| 37 | + ->filters([ |
| 38 | + SelectFilter::make('email_verified_status') |
| 39 | + ->label('Email verified status') |
| 40 | + ->options([ |
| 41 | + 'verified' => 'Verified', |
| 42 | + 'unverified' => 'Unverified', |
| 43 | + ]) |
| 44 | + ->query(function ($query, $state) { |
| 45 | + return match ($state['value']) { |
| 46 | + 'verified' => $query->whereNotNull('email_verified_at'), |
| 47 | + 'unverified' => $query->whereNull('email_verified_at'), |
| 48 | + default => $query, |
| 49 | + }; |
| 50 | + }), |
| 51 | + ], FiltersLayout::Modal) |
| 52 | + ->recordActions([ |
| 53 | + ViewAction::make(), |
| 54 | + ]) |
| 55 | + ->toolbarActions([ |
| 56 | + // |
| 57 | + ]); |
| 58 | + } |
| 59 | +} |
0 commit comments