I want to store fields in db even if they are not valid or empty as null, but I can't get this to work.
I have tried to cast the field to null but it always says "must be valid date".
return [
ImportColumn::make('salutation')
->rules(['max:255']),
ImportColumn::make('firstname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('lastname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('email')
->rules(['nullable', 'max:255']),
ImportColumn::make('phone')
->rules(['max:255']),
ImportColumn::make('whatsapp_number')
->rules(['max:255']),
ImportColumn::make('follow_up')
->castStateUsing(fn($state) => $state ? Carbon::parse($state) : null) // here for example
->rules(['max:255']),
ImportColumn::make('notes')
->rules(['max:10000']),
];
return [
ImportColumn::make('salutation')
->rules(['max:255']),
ImportColumn::make('firstname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('lastname')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('email')
->rules(['nullable', 'max:255']),
ImportColumn::make('phone')
->rules(['max:255']),
ImportColumn::make('whatsapp_number')
->rules(['max:255']),
ImportColumn::make('follow_up')
->castStateUsing(fn($state) => $state ? Carbon::parse($state) : null) // here for example