From 676401931d35e24ccf92d6d269b8b8a894263136 Mon Sep 17 00:00:00 2001 From: Victor R <39545521+viicslen@users.noreply.github.com> Date: Fri, 14 Jan 2022 13:13:17 -0500 Subject: [PATCH] Create MigrateMake Add --tenant option to create the migration file inside of the tenant migrations directory --- src/Commands/MigrateMake | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/Commands/MigrateMake diff --git a/src/Commands/MigrateMake b/src/Commands/MigrateMake new file mode 100644 index 00000000..d202a412 --- /dev/null +++ b/src/Commands/MigrateMake @@ -0,0 +1,39 @@ +signature .= ' + {--tenant : Create migration file in the tenant migrations directory.} + '; + + parent::__construct($creator, $composer); + } + + /** + * Get migration path (either specified by '--path' option or default location). + * + * @return string + */ + protected function getMigrationPath(): string + { + if (! is_null($targetPath = $this->input->getOption('path'))) { + return ! $this->usingRealPath() + ? $this->laravel->basePath().'/'.$targetPath + : $targetPath; + } + + if ($this->hasOption('tenant') && $this->option('tenant')) { + return parent::getMigrationPath().DIRECTORY_SEPARATOR.'tenant'; + } + + return parent::getMigrationPath(); + } +}