filament table hidden record null

this is my code , I want to hidden table column with condition
Tables\Columns\TextColumn::make('stok_sp_hd')
                    ->visible(fn (?Model $record) => $record?->category === "PERDANA LITE")
                    ->numeric()
                    ->sortable(),

the record always null
Solution
So to manage the label, I use a description to clarify the data.

TextColumn::make('stok_1')
    ->getStateUsing(fn (StockDigipos $record): int => $record->category === "PERDANA LITE" ? $record->stok_sp_ld : $record->stok_inj_357)
    ->description(fn (StockDigipos $record): string => $record->category === "PERDANA LITE" ? "Stok SP LD" : "STOK INJ 357"),


This explanation highlights the purpose of the description , emphasizing that it provides clarity regarding the data associated with each label.
Was this page helpful?