Hello, when i don't use WithBatchInserts concern, the Eloquent events of the imported model fire normally. But when i use WithBatchInserts it doesn't.
Is this intended? Any workaround?
Hey @pepinows batch inserts doesn't fire eloquent events, because we use Eloquent's ->insert() behind the scenes which doesn't emit it. You should handle all data mutations in the model() method.
Thanks for the reply! Is there any other way(non-manual) to validate the upload file entirely before throwing an exception without using WithBatchInserts?
No, that would defeat the purpose of the batch inserts / chunk reading as we then have to load the entire file into memory (performance).
Closing due to resolved/inactivity. Please feel free to reopen if you need additional support.
Most helpful comment
Hey @pepinows batch inserts doesn't fire eloquent events, because we use Eloquent's
->insert()behind the scenes which doesn't emit it. You should handle all data mutations in themodel()method.