2026-04-03 04:22:34 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Filament\Resources\Users\Tables;
|
|
|
|
|
|
|
|
|
|
use App\Models\Division;
|
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
|
|
|
use Filament\Actions\DeleteBulkAction;
|
|
|
|
|
use Filament\Actions\EditAction;
|
|
|
|
|
use Filament\Tables\Columns\TextColumn;
|
|
|
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
|
|
|
use Filament\Tables\Table;
|
2026-04-03 06:33:13 +07:00
|
|
|
use STS\FilamentImpersonate\Actions\Impersonate;
|
2026-04-03 04:22:34 +07:00
|
|
|
|
|
|
|
|
class UsersTable
|
|
|
|
|
{
|
|
|
|
|
public static function configure(Table $table): Table
|
|
|
|
|
{
|
|
|
|
|
return $table
|
|
|
|
|
->columns([
|
|
|
|
|
TextColumn::make('name')->searchable()->sortable(),
|
|
|
|
|
TextColumn::make('email')->searchable(),
|
|
|
|
|
TextColumn::make('phone')->label('Telepon'),
|
|
|
|
|
TextColumn::make('division.name')->label('Divisi')->sortable(),
|
|
|
|
|
TextColumn::make('status')->badge()
|
|
|
|
|
->color(fn ($state) => $state === 'aktif' ? 'success' : 'danger'),
|
2026-04-05 22:52:07 +07:00
|
|
|
TextColumn::make('roles.name')->label('Role')->badge()
|
|
|
|
|
->getStateUsing(fn ($record) => $record->roles->pluck('name')->filter(fn ($r) => $r !== 'anggota')->values())
|
|
|
|
|
->placeholder('-'),
|
2026-04-03 04:22:34 +07:00
|
|
|
])
|
|
|
|
|
->filters([
|
|
|
|
|
SelectFilter::make('status')
|
|
|
|
|
->options(['aktif' => 'Aktif', 'nonaktif' => 'Nonaktif']),
|
|
|
|
|
SelectFilter::make('division_id')->label('Divisi')
|
|
|
|
|
->options(Division::pluck('name', 'id')),
|
|
|
|
|
])
|
2026-04-03 06:33:13 +07:00
|
|
|
->recordActions([EditAction::make(), Impersonate::make()])
|
2026-04-03 04:22:34 +07:00
|
|
|
->toolbarActions([BulkActionGroup::make([DeleteBulkAction::make()])]);
|
|
|
|
|
}
|
|
|
|
|
}
|