From 8bb1d11ff8e70707ff4dd2a91d6cfcbf9332542b Mon Sep 17 00:00:00 2001 From: Abed Halawi Date: Wed, 16 May 2018 23:40:33 +0300 Subject: [PATCH] add make:migration command --- src/Commands/MigrationMakeCommand.php | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/Commands/MigrationMakeCommand.php diff --git a/src/Commands/MigrationMakeCommand.php b/src/Commands/MigrationMakeCommand.php new file mode 100644 index 0000000..40b35ba --- /dev/null +++ b/src/Commands/MigrationMakeCommand.php @@ -0,0 +1,70 @@ + + * + * 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 + */ +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 '.$path.''."\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.'], + ]; + } +}