FilamentF
Filament14mo ago
Guido

Conditionally hide SelectColumn based on email domain

I'm working on a Laravel project using FilamentPHP and need some help conditionally hiding a column in a table.
public static function table(Table $table): Table
{
    return $table
        ->columns([
            Tables\Columns\TextColumn::make('name')
                ->searchable(),
            Tables\Columns\TextColumn::make('email')
                ->searchable(),
            Tables\Columns\SelectColumn::make('department_id')
                ->label('Department')
                ->options(Department::all()->pluck('name', 'id')),
        ]);
}

The department_id column should only display when the user’s email address does end with @mycompany.com. If it doesn't, I'd like this column to be hidden for that specific row.

Is there a way to conditionally hide a column based on a record's attribute like this in FilamentPHP?
Was this page helpful?