F
Filament3mo ago
MAF

I want to generate dynamic ExportColumn!

Is there anyway to access $record inside getColumns(), in my case, I want to generate dynamic ExportColumn! i.e., if I have a JSON field, I want to break it down to multiple columns while exporting.
1 Reply
nanopanda
nanopanda3mo ago
Yes, you can access $record in the ->formatStateUsing closure. For example:
ExportColumn::make('tags')
->formatStateUsing( function (Customer $record ): string {
return $record->tags?->pluck('name')->implode(',');
}),
ExportColumn::make('tags')
->formatStateUsing( function (Customer $record ): string {
return $record->tags?->pluck('name')->implode(',');
}),
Want results from more Discord servers?
Add your server