public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('username')->searchable(isIndividual: true, isGlobal: false),
TextColumn::make('email')->searchable(isIndividual: true, isGlobal: false),
TextColumn::make('roles.name')->label('Role'),
TextColumn::make('lastlogin')->dateTime('d-m-Y H:i:s')->label('Last Login'),
TextColumn::make('apiaccess')->dateTime('d-m-Y H:i:s')->label('Last API'),
IconColumn::make('verified')->boolean(),
IconColumn::make('bad_user')->boolean()->label('Bad User'),
IconColumn::make('passwordsecurity.google2fa_enable')->boolean()->label('2FA')->default(0),
])
->filters(
[
],
layout: \Filament\Tables\Enums\FiltersLayout::AboveContent,
)
->actions([
Tables\Actions\ViewAction::make()->slideOver(),
Tables\Actions\EditAction::make()->slideOver()->after(function (User $record, Role $role) {
$record->syncRoles($record->role->name);
$role = $role->findByName($record->role->name);
$record->givePermissionTo($role->findByName($record->role->name, null)->permissions->pluck('name'));
}),
Tables\Actions\Action::make('disable')
->label('2FA')
->action(fn (User $record) => $record->disable2FA())
->requiresConfirmation()
->icon('heroicon-o-lock-closed')
->color('danger'),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make()
->requiresConfirmation(),
]);
}