Model observer seems to hang and run synchronously during each loop

Posted 1 month ago by lambooni

I have the code:

$model->each(function (Model $model){
    dump('Gets here for every row of loop');
    $model->doSomethingThatCreatesOrUpdatesAnotherModel();
    dd('Never gets here??');
});

This is setup with a model observer on the AnotherModel class

AnotherModel::observe(AnotherModelObserver::class);

And the observer class made using the artisan command.

When I run the code, my loop dumps out Gets here for every row of loop for every row of the loop, but never gets past the model create function. It is like the observer is hanging and the rest of the code is running synchronously...

Please sign in or create an account to participate in this conversation.