#Suppressing specific events on models?

3 messages · Page 1 of 1 (latest)

ripe torrent
#

I'm writing an integration package with a third party system to synchronise and attribute resources to/from our services to/from the third party application.

I have a trait which adds various events to the model's event lifecycle, and currently have a boolean property which I've been calling to disable these events firing when the boolean property is set to true, however I'm struggling to come up with a way of suppressing these events specifically when i want other lifecycle events to fire, for example -

I want UUIDs to generate during the 'create' of a Model::updateOrCreate() operation, but I don't necessarily want my package's events to fire.

Using the method mentioned above I can replace updateOrCreate()'s with:

$model = Model::firstOrNew(['unique_key' => $row['unique_key']);
$model->notSync();
$model->name = $row['name];
...etc
$model->save();

However, this is neither elegant nor will it transfer over to larger resource syncs where we use an Model::upsert() operation, where we need inserts to have new UUID's generated en mass, so are unable to pass a manual UUID to the upsert.

Any suggestions?

dreamy sand
#

you can use saveQuietly

ripe torrent