F
Filament2mo ago
bouly

Import rules

Hello, I am trying to import users using the default importer feature. But I'm encountering several problems. 1. I can't get the rules to work.
ImportColumn::make(‘email’)
->rules([
‘required’, ‘email’
])
->requiredMapping(),
ImportColumn::make(‘email’)
->rules([
‘required’, ‘email’
])
->requiredMapping(),
Unfortunately, even with this code, I keep getting errors like this:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘email’ cannot be null
SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘email’ cannot be null
2. When these errors occur, my job restarts indefinitely even though I ran this command:
php artisan queue:work --tries=1
php artisan queue:work --tries=1
So, I never receive the import completion notification. And my “failed_import_rows” table fills up indefinitely. Should I try/catch in resolveRecord to throw RowImportFailedException? Thanks for your help!
2 Replies
Tieme
Tieme2mo ago
you can try ->ignoreBlankState() and in the public function resolveRecord(): ?Product { Log::debug('Import row email column',$this->data['email']) } and look at the log to see what is being logged.
bouly
boulyOP2mo ago
It does not work. It seems that the rules() and ignoreBlankState() are ignored... Do not know why?! The only thing I can do is check the rules and thrwo exceptions manually in resolveRecord(). Really strange.

Did you find this page helpful?