Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

juanborras's avatar

Filament Importer, skip one record import

Hello All

Is there any way to "cancel" one record import and skip to the next one in filament?

Thanks!

0 likes
2 replies
LaryAI's avatar
Level 58

To skip a record during an import process in Filament, you can utilize the beforeImport or importing hooks provided by the Filament Importer. These hooks allow you to inspect each record before it is processed and decide whether to skip it.

Here's a basic example of how you might implement this:

use Filament\Import\Importers\Importer;

class YourCustomImporter extends Importer
{
    public function importing(array $row): ?array
    {
        // Add your condition to skip a record
        if ($this->shouldSkip($row)) {
            // Return null to skip this record
            return null;
        }

        // Return the row if it should be processed
        return $row;
    }

    protected function shouldSkip(array $row): bool
    {
        // Implement your logic to determine if the row should be skipped
        // For example, skip if a certain column is empty
        return empty($row['some_column']);
    }
}

In this example, the importing method is used to check each row. If the shouldSkip method returns true, the row is skipped by returning null. Otherwise, the row is returned and processed normally.

Make sure to replace 'some_column' with the actual column name you want to check, and adjust the logic in shouldSkip to fit your specific requirements.

juanborras's avatar

Found it. Just have resolveRecord to return null...

Please or to participate in this conversation.