Features

Events

Lifecycle events dispatched during the import process.

Tapix dispatches events at key points during the import lifecycle. You can listen to these events to trigger notifications, log activity, update dashboards, or perform any custom logic.

Available Events

use Tapix\Core\Events\ImportStarted;
use Tapix\Core\Events\ImportRowProcessed;
use Tapix\Core\Events\ImportCompleted;
use Tapix\Core\Events\ImportFailed;

ImportStarted

Dispatched when ExecuteImportJob begins processing an import.

PropertyTypeDescription
$importImportThe import model instance.

ImportRowProcessed

Dispatched after each chunk of rows is processed during ExecuteImportJob. Use this event for real-time progress tracking.

PropertyTypeDescription
$importImportThe import model instance.
$processedCountintNumber of rows processed so far.
$totalCountintTotal number of rows in the import.

ImportCompleted

Dispatched when the import finishes successfully with all rows processed.

PropertyTypeDescription
$importImportThe import model instance.

ImportFailed

Dispatched when the import fails due to an unrecoverable exception.

PropertyTypeDescription
$importImportThe import model instance.

Listener Example

Create a listener to respond to import completion:

app/Listeners/SendImportReport.php
use Tapix\Core\Events\ImportCompleted;

class SendImportReport
{
    public function handle(ImportCompleted $event): void
    {
        $import = $event->import;

        logger()->info("Import completed", [
            'id' => $import->id,
            'created' => $import->created_rows,
            'updated' => $import->updated_rows,
            'skipped' => $import->skipped_rows,
            'failed' => $import->failed_rows,
        ]);
    }
}

Register the listener in your EventServiceProvider or use Laravel's automatic event discovery.

Progress Tracking

The ImportRowProcessed event enables real-time progress tracking. Since it fires after each chunk, you can calculate the percentage and broadcast updates to the frontend:

app/Listeners/TrackImportProgress.php
use Tapix\Core\Events\ImportRowProcessed;

class TrackImportProgress
{
    public function handle(ImportRowProcessed $event): void
    {
        $percentage = ($event->processedCount / $event->totalCount) * 100;

        broadcast(new ImportProgressUpdated(
            importId: $event->import->id,
            percentage: round($percentage, 1),
            processed: $event->processedCount,
            total: $event->totalCount,
        ));
    }
}

This pairs well with a frontend component that listens for broadcast events to display a live progress bar during import execution.

Copyright © 2026