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

Commit 46649fd

Browse files
committed
Delegating male:migration to Laravel's command. We just specify the path it needs.
1 parent 03e0e0c commit 46649fd

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

lucid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ $commands = [
1818
new Lucid\Console\Commands\FeatureMakeCommand(),
1919
new Lucid\Console\Commands\FeatureDeleteCommand(),
2020
new Lucid\Console\Commands\ControllerMakeCommand(),
21+
new Lucid\Console\Commands\MigrationMakeCommand(),
2122
new Lucid\Console\Commands\ServicesListCommand(),
2223
new Lucid\Console\Commands\FeaturesListCommand(),
2324

src/Commands/MigrationMakeCommand.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
* @return void
46+
*/
47+
public function handle()
48+
{
49+
$service = $this->argument('service');
50+
$migration = $this->argument('migration');
51+
52+
$path = $this->findServicePath($service) . "/database/migrations";
53+
54+
Artisan::call('make:migration', ['name' => $migration, '--path' => $path]);
55+
56+
$this->info('Migration class created successfully.' . "\n" . "\n" . 'Find it at <comment>' . $path . '</comment>' . "\n");
57+
}
58+
59+
/**
60+
* Get the console command arguments.
61+
*
62+
* @return array
63+
*/
64+
protected function getArguments()
65+
{
66+
return [
67+
['migration', InputArgument::REQUIRED, 'The migration\'s name.'],
68+
['service', InputArgument::REQUIRED, 'The service in which the migration should be generated.'],
69+
];
70+
}
71+
}

0 commit comments

Comments
 (0)