1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 16:54:05 +00:00

Create MigrateMake

Add --tenant option to create the migration file inside of the tenant migrations directory
This commit is contained in:
Victor R 2022-01-14 13:13:17 -05:00 committed by GitHub
parent f08e33afd8
commit 676401931d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

39
src/Commands/MigrateMake Normal file
View file

@ -0,0 +1,39 @@
<?php
namespace Stancl\Tenancy\Commands;
use Illuminate\Database\Console\Migrations\MigrateMakeCommand;
use Illuminate\Database\Migrations\MigrationCreator;
use Illuminate\Support\Composer;
class MigrateMake extends MigrateMakeCommand
{
public function __construct(MigrationCreator $creator, Composer $composer)
{
$this->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();
}
}