Iam bulk-inserting large database in chunks with this command:
DB::table($table)->insert($chunk);
But want I want is before actual insert
operation, I want to be able to modify $chunk
array for each table to add/remove certain attributes going into database. In order to do so, I setup saving
event in my model:
public static function boot()
{
parent::boot();
static::saving(function ($model) {
Log::info('saving');
return true;
});
}
However, it seems events don't work for Model::insert
operations.
Can anybody tell how can I achieve this ?
PS: I can't use save()
(though saving event would work with it) method as it would only allow me to save one record at a time whereas I need to do bulk insert of each chunk.
Thanks