Total Complexity | 3 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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'))); |
||
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 | } |
||
43 |