Skip to content

Commit

Permalink
[11.x] Change scope for afterCreating and afterMaking callbacks (#…
Browse files Browse the repository at this point in the history
…51772)

* Change scope for `afterCreating` and `afterMaking` callbacks

* Update Factory.php

---------

Co-authored-by: Jacob Fricke <jacob.fricke@sense-it.de>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
3 people authored Jun 11, 2024
1 parent 7aef671 commit 202422d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ protected function callAfterMaking(Collection $instances)
{
$instances->each(function ($model) {
$this->afterMaking->each(function ($callback) use ($model) {
$callback($model);
Closure::fromCallable($callback)->call($this, $model);
});
});
}
Expand All @@ -710,7 +710,7 @@ protected function callAfterCreating(Collection $instances, ?Model $parent = nul
{
$instances->each(function ($model) use ($parent) {
$this->afterCreating->each(function ($callback) use ($model, $parent) {
$callback($model, $parent);
Closure::fromCallable($callback)->call($this, $model, $parent);
});
});
}
Expand Down

0 comments on commit 202422d

Please sign in to comment.