Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anonymouse703's avatar

How to fetch activeTab for visibility in filter (resource)

I want to show the role filter on the admin tab only

So I have this table tab in ListUsers.php

 public function getTabs(): array
    {
        return [
            'all' => Tab::make(),
            'admin' => Tab::make()
                ->modifyQueryUsing(fn (Builder $query) => $query->where('role', [Role::SuperAdmin, Role::Admin, Role::Csr, Role::Auditor])),
            'customer' => Tab::make()
                ->modifyQueryUsing(fn (Builder $query) => $query->where('role', Role::Customer)),
        ];
    }
	```


and in the UsersResource I have this filter

Tables\Filters\SelectFilter::make('role') ->options([ Role::SuperAdmin->value => 'Super Admin', Role::Admin->value => 'Admin', Role::Csr->value => 'Csr', Role::Auditor->value => 'Auditor', ]) ->label('Role') ->visible(fn () => request()->get('activeTab') === 'admin')

it will only work if you refresh the page but if you just do clicking it will not working

 ->visible(fn () => request()->get('activeTab') === 'admin')
0 likes
0 replies

Please or to participate in this conversation.