From 7790c83208ac98fd15e6bf042b2ef881d61dc381 Mon Sep 17 00:00:00 2001 From: ell Date: Tue, 20 Dec 2016 13:09:17 +0300 Subject: [PATCH] Add nullable morph columns --- src/Illuminate/Database/Schema/Blueprint.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index e6c5c54343b2..369307d07c5c 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -901,6 +901,22 @@ public function morphs($name, $indexName = null) $this->index(["{$name}_id", "{$name}_type"], $indexName); } + /** + * Add nullable proper columns for a polymorphic table. + * + * @param string $name + * @param string|null $indexName + * @return void + */ + public function nullableMorphs($name, $indexName = null) + { + $this->unsignedInteger("{$name}_id")->nullable(); + + $this->string("{$name}_type")->nullable(); + + $this->index(["{$name}_id", "{$name}_type"], $indexName); + } + /** * Adds the `remember_token` column to the table. *