diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 8497432..4cb5d11 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -54,6 +54,18 @@ protected function macros() : void Blueprint::macro('foreignSnowflakeFor', function($model, $column = null) { return $this->foreignSnowflake($column ?: (new $model())->getForeignKey()); }); + + Blueprint::macro('snowflakeMorphs', function ($name, $indexName = null) { + $this->string("{$name}_type"); + $this->unsignedBigInteger("{$name}_id"); + $this->index(["{$name}_type", "{$name}_id"], $indexName); + }); + + Blueprint::macro('nullableSnowflakeMorphs', function ($name, $indexName = null) { + $this->string("{$name}_type")->nullable(); + $this->unsignedBigInteger("{$name}_id")->nullable(); + $this->index(["{$name}_type", "{$name}_id"], $indexName); + }); } /**