<?php

namespace Modules\Identity\Filament\Resources\Roles\Tables;

use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;

class RolesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->modifyQueryUsing(fn (Builder $query) => $query->withCount(['permissions', 'users']))
            ->columns([
                TextColumn::make('name')
                    ->badge()
                    ->sortable(),
                TextColumn::make('permissions_count')
                    ->label('Permissions'),
                TextColumn::make('users_count')
                    ->label('Staff'),
            ])
            ->recordActions([
                EditAction::make(),
            ]);
    }
}
