Guido
Guido
FFilament
Created by Guido on 11/10/2024 in #❓┊help
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')),
]);
}
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?
8 replies