F
Filament5mo ago
Zoltar

Filament Importer skip import row if certain conditions is true

I create a simple importer that import only one column "email". The importer works properly, now i try to stop import row if email has already been imported I try to use beforeValidate hooks, but it doesn't seem to work. alternative to $this->action->halt(); ??? thank you always for your availability
protected function beforeValidate(): void
{
$user = User::where('email', $this->data['email'])->first();
if ($user) {
Notification::make()
->danger()
->title('User already exist')
->body('This email has already been used for a user on the platform')
->persistent()
->send();

$this->action->halt();
}
}
protected function beforeValidate(): void
{
$user = User::where('email', $this->data['email'])->first();
if ($user) {
Notification::make()
->danger()
->title('User already exist')
->body('This email has already been used for a user on the platform')
->persistent()
->send();

$this->action->halt();
}
}
Solution:
ok its worked, i add the code in public function resolveRecord() function and use Filament\Actions\Imports\Exceptions\RowImportFailedException;
No description
Jump to solution
1 Reply
Solution
Zoltar
Zoltar5mo ago
ok its worked, i add the code in public function resolveRecord() function and use Filament\Actions\Imports\Exceptions\RowImportFailedException;
No description
Want results from more Discord servers?
Add your server