1 | <?php |
||
2 | |||
3 | namespace Orkhanahmadov\ContentMigrations\Console; |
||
4 | |||
5 | use Illuminate\Database\Console\Migrations\MigrateMakeCommand as Command; |
||
6 | use Illuminate\Support\Collection; |
||
7 | use Illuminate\Support\Str; |
||
8 | |||
9 | class MigrateMakeCommand extends Command |
||
10 | { |
||
11 | protected $signature = 'make:content-migration {name : The name of the content migration}'; |
||
12 | |||
13 | protected $description = 'Create a new content migration file'; |
||
14 | |||
15 | public function handle() |
||
16 | { |
||
17 | $name = Str::snake(trim($this->input->getArgument('name'))); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
18 | |||
19 | $this->writeMigration($name); |
||
20 | |||
21 | $this->composer->dumpAutoloads(); |
||
22 | } |
||
23 | |||
24 | protected function writeMigration($name, $table = null, $create = null) |
||
25 | { |
||
26 | // Needed for Laravel 6 and 7 support. Laravel 8 handles creating folder automatically |
||
27 | // @codeCoverageIgnoreStart |
||
28 | if (! file_exists(database_path('content-migrations'))) { |
||
29 | mkdir(database_path('content-migrations'), 0755); |
||
30 | } |
||
31 | // @codeCoverageIgnoreEnd |
||
32 | |||
33 | $file = $this->creator->create( |
||
34 | $name, |
||
35 | $this->laravel->databasePath() . DIRECTORY_SEPARATOR . 'content-migrations' |
||
36 | ); |
||
37 | |||
38 | $fileName = basename($file); |
||
39 | |||
40 | $this->line("<info>Created Content Migration:</info> {$fileName}"); |
||
41 | } |
||
42 | } |
||
43 |