How to use hidden() in a table programmatically

I need to hide a column if another column doesn't have a given value. But this doesn't work on any way.
Tables\Columns\SelectColumn::make('rate')
->options([
'1' => '1 star',
'2' => '2 stars',
'3' => '3 stars',
'4' => '4 stars',
'5' => '5 stars',
])
->hidden(function(Closure $get) {
return $get('status') !== 'approved';
})
->label('Calificación'),
Tables\Columns\SelectColumn::make('rate')
->options([
'1' => '1 star',
'2' => '2 stars',
'3' => '3 stars',
'4' => '4 stars',
'5' => '5 stars',
])
->hidden(function(Closure $get) {
return $get('status') !== 'approved';
})
->label('Calificación'),
3 Replies
Patrick Boivin
Patrick Boivin17mo ago
Try $record instead
->hidden(fn ($record) => $record->status !== 'approved')
->hidden(fn ($record) => $record->status !== 'approved')
LeandroFerreira
LeandroFerreira17mo ago
Actually you can use disable() You can't show/hide column by row ->disable(fn($record) => $record->status !== 'approved')
Alejandro
AlejandroOP17mo ago
It worked, thanks!
Want results from more Discord servers?
Add your server