Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

booni3's avatar

Model observer seems to hang and run synchronously during each loop

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...

0 likes
0 replies

Please or to participate in this conversation.