Jun 16, 2019
0
Level 3
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...
Please or to participate in this conversation.