Laravel-excel: WithBatchInserts eloquent events not firing

Created on 30 May 2019  路  4Comments  路  Source: Maatwebsite/Laravel-Excel

Versions

  • PHP version: 7.1.26
  • Laravel version: 5.6.39
  • Package version: 3.1

Description

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?

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 the model() method.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amine8ghandi8amine picture amine8ghandi8amine  路  3Comments

contifico picture contifico  路  3Comments

thearabbit picture thearabbit  路  3Comments

pamekar picture pamekar  路  3Comments

wwendorf picture wwendorf  路  3Comments