mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 11:14:03 +00:00
Create MigrateMake
Add --tenant option to create the migration file inside of the tenant migrations directory
This commit is contained in:
parent
f08e33afd8
commit
676401931d
1 changed files with 39 additions and 0 deletions
39
src/Commands/MigrateMake
Normal file
39
src/Commands/MigrateMake
Normal 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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue