From ba0a0b995aec7b72863a764d4833b46611077eff Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Wed, 18 Sep 2024 20:15:37 -0300 Subject: [PATCH] Add logic to support model table discovery in migrations --- src/Illuminate/Database/Schema/Builder.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Illuminate/Database/Schema/Builder.php b/src/Illuminate/Database/Schema/Builder.php index 9f5dbaa5f0e0..4bd6f1090927 100755 --- a/src/Illuminate/Database/Schema/Builder.php +++ b/src/Illuminate/Database/Schema/Builder.php @@ -5,6 +5,7 @@ use Closure; use Illuminate\Container\Container; use Illuminate\Database\Connection; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; use LogicException; @@ -578,6 +579,10 @@ protected function createBlueprint($table, ?Closure $callback = null) ? $this->connection->getConfig('prefix') : ''; + if (class_exists($table) && $table instanceof Model) { + $table = (new $table)->getTable(); + } + if (isset($this->resolver)) { return call_user_func($this->resolver, $table, $callback, $prefix); }