Serialization of 'Closure' is not allowed

While exporting a table to CSV it gives error Serialization of 'Closure' is not allowed
TextColumn::make("stage")
->badge()
->label(__('multifamily-mindset::multifamily-mindset.resources.opportunity.stage'))
->extraAttributes(function($state){
return self::getExtraAttributes($state);
})
public static function getExtraAttributes($state) {

$allStages = [
'lead' => 'color-7',
'customer' => 'color-8',
'student' => 'color-9',
];
return [
'class' => $allStages[$state]
];
}
TextColumn::make("stage")
->badge()
->label(__('multifamily-mindset::multifamily-mindset.resources.opportunity.stage'))
->extraAttributes(function($state){
return self::getExtraAttributes($state);
})
public static function getExtraAttributes($state) {

$allStages = [
'lead' => 'color-7',
'customer' => 'color-8',
'student' => 'color-9',
];
return [
'class' => $allStages[$state]
];
}
8 Replies
Dennis Koch
Dennis Koch2w ago
That might be because of the extra attributes Closure. Are you using a plugin for exporting or Filament's exporter?
GHOST-117
GHOST-1176d ago
Filament
Excel Export by Dennis Koch - Filament
Easy Excel exports for Filament Admin
GHOST-117
GHOST-1176d ago
in UI i have to show the status is there a way ????..
No description
toeknee
toeknee6d ago
Try the native filament export?
Dennis Koch
Dennis Koch6d ago
You could try to define the columns manually instead of relying on fromTable()
GHOST-117
GHOST-1176d ago
this is my function
public static function ExportJob(): array
{
if (cache('totalRecords-' . auth()->user()->id) < 2000) {
return [ExcelExport::make()->fromTable()->withWriterType(\Maatwebsite\Excel\Excel::CSV)];
}
return [ExcelExport::make()->fromTable()->queue()->withWriterType(\Maatwebsite\Excel\Excel::CSV)];
}
public static function ExportJob(): array
{
if (cache('totalRecords-' . auth()->user()->id) < 2000) {
return [ExcelExport::make()->fromTable()->withWriterType(\Maatwebsite\Excel\Excel::CSV)];
}
return [ExcelExport::make()->fromTable()->queue()->withWriterType(\Maatwebsite\Excel\Excel::CSV)];
}
as per ur saying i should define a column array & pass like this
$columns = [
'column1' => 'Column 1 Title',
'column2' => 'Column 2 Title',

];
return [ExcelExport::make()->withColumns($columns)->queue()->withWriterType(\Maatwebsite\Excel\Excel::CSV)];
$columns = [
'column1' => 'Column 1 Title',
'column2' => 'Column 2 Title',

];
return [ExcelExport::make()->withColumns($columns)->queue()->withWriterType(\Maatwebsite\Excel\Excel::CSV)];
Dennis Koch
Dennis Koch6d ago
That's not how you define columns. Check the docs
GHOST-117
GHOST-1176d ago
got it