From 5317f9787060d710e09f59ece4ed34aaebbc7893 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 6 Dec 2024 13:02:37 +0100 Subject: [PATCH] Display roles as badge in user list (#772) --- .../Resources/UserResource/Pages/ListUsers.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 640b54ddd7..92021e4725 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -50,12 +50,13 @@ public function table(Table $table): Table ->label('2FA') ->visibleFrom('lg') ->icon(fn (User $user) => $user->use_totp ? 'tabler-lock' : 'tabler-lock-open-off') - ->boolean()->sortable(), - TextColumn::make('roles_count') - ->counts('roles') - ->icon('tabler-users-group') + ->boolean() + ->sortable(), + TextColumn::make('roles.name') ->label('Roles') - ->formatStateUsing(fn (User $user, $state) => $state . ($user->isRootAdmin() ? ' (Root Admin)' : '')), + ->badge() + ->icon('tabler-users-group') + ->placeholder('No roles'), TextColumn::make('servers_count') ->counts('servers') ->icon('tabler-server') @@ -65,7 +66,6 @@ public function table(Table $table): Table ->label('Subusers') ->counts('subusers') ->icon('tabler-users'), - // ->formatStateUsing(fn (string $state, $record): string => (string) ($record->servers_count + $record->subusers_count)) ]) ->actions([ EditAction::make(),