Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
add make:migration command
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulkave committed May 16, 2018
1 parent 17ee84b commit 8bb1d11
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/Commands/MigrationMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/*
* This file is part of the lucid-console project.
*
* (c) Vinelab <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Lucid\Console\Commands;

use Illuminate\Support\Facades\Artisan;
use Lucid\Console\Command;
use Lucid\Console\Finder;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputArgument;

/**
* @author Abed Halawi <[email protected]>
*/
class MigrationMakeCommand extends SymfonyCommand
{
use Finder;
use Command;

/**
* The console command name.
*
* @var string
*/
protected $name = 'make:migration';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new Migration class in a service';

/**
* Execute the console command.
*/
public function handle()
{
$service = $this->argument('service');
$migration = $this->argument('migration');

$path = $this->relativeFromReal($this->findServicePath($service) . "/database/migrations");

$output = shell_exec('php artisan make:migration '.$migration.' --path='.$path);

$this->info($output);
$this->info("\n".'Find it at <comment>'.$path.'</comment>'."\n");
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['migration', InputArgument::REQUIRED, 'The migration\'s name.'],
['service', InputArgument::REQUIRED, 'The service in which the migration should be generated.'],
];
}
}

0 comments on commit 8bb1d11

Please sign in to comment.