How to covert enum value on Export Column?
There is an upgrade guide but doesn't show on the enum values part
Error:
Filament\Actions\Exports\ExportColumn::getFormattedState(): Return value must be of type ?string, App\Enums\Company
Exporter column
Enums
2 Replies
You can find all about enums in filament apps in the documentation:
https://filamentphp.com/docs/4.x/advanced/enums
I already know the enums.. in the v3
I do somehting like this
ExportColumn::make('type')
->formatStateUsing(fn ($state) => $state instanceof \App\Services\Points\Enums\Type ? $state->labelAdmin() : ucfirst((string) $state)),
but in the v4 it's not working anymore.. and in the import also this not working
ImportColumn::make('mobile')
->requiredMapping()
->rules([
'nullable',
'phone:PH',
'max:255',
])
->fillRecordUsing(function ($record, $state) {
if (empty($state)) {
$record->mobile = null;
return;
}
$record->mobile = (new PhoneNumber($state, 'PH'))->formatE164();
}),
wasted time.. fixed by restarting queue