Skip to content

Commit

Permalink
Added path option for compiled migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sunel committed Sep 4, 2018
1 parent d4f251b commit 8d96c17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Console/EntityComplierCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class EntityComplierCommand extends Command
*
* @var string
*/
protected $signature = 'eav:compile:entity {entity : The name of the entity.}';
protected $signature = 'eav:compile:entity {entity : The name of the entity.}
{--path= : The location where the compiled migration file should be created.}';

/**
* The console command description.
Expand Down
8 changes: 7 additions & 1 deletion src/Flat/Entity/Complier.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ protected function createTable()
$this->console->info("\t Creating flat table for `{$this->entity->entity_table}`.");

$path = $this->getPath($this->entity->entity_table.'_flat');

$this->console->info("\t in {$path}");

$this->makeDirectory($path);

Expand Down Expand Up @@ -187,7 +189,11 @@ protected function makeDirectory($path)
*/
protected function getPath($name)
{
return base_path() . '/database/migrations/eav/' . $name . '.php';
if (! is_null($targetPath = $this->console->option('path'))) {
return $this->console->getLaravel()->basePath().'/'.rtrim(trim($targetPath), '/').'/'. $name . '.php';
}

return $this->console->getLaravel()->databasePath().'/migrations/eav/' . $name . '.php';
}

/**
Expand Down

0 comments on commit 8d96c17

Please sign in to comment.