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

Commit 8bb1d11

Browse files
committed
add make:migration command
1 parent 17ee84b commit 8bb1d11

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

src/Commands/MigrationMakeCommand.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console\Commands;
13+
14+
use Illuminate\Support\Facades\Artisan;
15+
use Lucid\Console\Command;
16+
use Lucid\Console\Finder;
17+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
18+
use Symfony\Component\Console\Input\InputArgument;
19+
20+
/**
21+
* @author Abed Halawi <[email protected]>
22+
*/
23+
class MigrationMakeCommand extends SymfonyCommand
24+
{
25+
use Finder;
26+
use Command;
27+
28+
/**
29+
* The console command name.
30+
*
31+
* @var string
32+
*/
33+
protected $name = 'make:migration';
34+
35+
/**
36+
* The console command description.
37+
*
38+
* @var string
39+
*/
40+
protected $description = 'Create a new Migration class in a service';
41+
42+
/**
43+
* Execute the console command.
44+
*/
45+
public function handle()
46+
{
47+
$service = $this->argument('service');
48+
$migration = $this->argument('migration');
49+
50+
$path = $this->relativeFromReal($this->findServicePath($service) . "/database/migrations");
51+
52+
$output = shell_exec('php artisan make:migration '.$migration.' --path='.$path);
53+
54+
$this->info($output);
55+
$this->info("\n".'Find it at <comment>'.$path.'</comment>'."\n");
56+
}
57+
58+
/**
59+
* Get the console command arguments.
60+
*
61+
* @return array
62+
*/
63+
protected function getArguments()
64+
{
65+
return [
66+
['migration', InputArgument::REQUIRED, 'The migration\'s name.'],
67+
['service', InputArgument::REQUIRED, 'The service in which the migration should be generated.'],
68+
];
69+
}
70+
}

0 commit comments

Comments
 (0)