Skip to content

Commit

Permalink
[9.x] Fixes constructable migrations (#46223)
Browse files Browse the repository at this point in the history
* Fixes migrator on migrations with constructors

* Update Migrator.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
nunomaduro and taylorotwell authored Feb 22, 2023
1 parent 7a5774a commit 0045c8a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ protected function resolvePath(string $path)
$migration = static::$requiredPathCache[$path] ??= $this->files->getRequire($path);

if (is_object($migration)) {
return clone $migration;
return method_exists($migration, '__construct')
? $this->files->getRequire($path)
: clone $migration;
}

return new $class;
Expand Down

0 comments on commit 0045c8a

Please sign in to comment.