All events are final readonly and dispatched after the surrounding transaction commits (ShouldDispatchAfterCommit). Unless noted, each carries $audit — an ImportAudit with sessionId, batchId, importer, owner, the actor of that operation (uploader, committer or the user who undid it), the file (a FileReference: disk, path, originalName, size, sha256, format), counts and at.
| Event | Extra payload | When |
|---|---|---|
ImportUploaded · ImportMapped · ImportPreviewed | — | A file was uploaded, mapped, previewed. |
ImportPreviewProgressed | processed, total | Every preview.progress_every rows. |
ImportPreviewFailed | reason | The error message (≤ 500 characters), or abandoned when imports:sweep released a lost validation. |
ImportStarted | — | Just before the dispatch; a refused dispatch follows it with ImportFailed (dispatch_failed). |
ImportChunkProcessed | chunk, rows, summary | After each chunk — running totals. |
ImportCompleted | summary | The batch finished. |
ImportFailed | reason, summary | chunk_failed, unauthorized, abandoned or dispatch_failed — resumable. |
ImportCancelled · ImportResumed | — | A batch was cancelled or resumed. |
ImportRollbackStarted | — | An undo started. |
ImportRolledBack | report | The undo finished — a RollbackReport. |
ImportRollbackFailed | reason | chunk_failed or abandoned — can be started again inside the undo window. |
ImportDiscarded · ImportExpired | — | A session was discarded, or expired by imports:sweep. |
MappingSaved | owner, actor, importer, mapping, sessionId | No audit. sessionId is null when saved by host code through mappings()->save(). |
MappingDeleted | owner, actor, importer, name | No audit. |
ImportsPruned | report | A PruneReport, no audit. |
Listeners of a batch’s ImportCompleted and ImportFailed run inside the owner’s context. A session whose owner was deleted is still closed by housekeeping — failed, its undo finished or expired, its lock released — but fires no event, because the audit names the owner.
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Imports\Events\ImportCompleted;
Event::listen(function (ImportCompleted $event): void {
$event->audit->actor?->notify(new ImportFinished(
importer: $event->audit->importer,
file: $event->audit->file->originalName,
created: $event->summary->created,
failed: $event->summary->failed,
));
});Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.