Conditions | 3 |
Paths | 3 |
Total Lines | 29 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.125 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | 3 | public function handle(Filesystem $file) |
|
24 | { |
||
25 | 3 | $table = strtolower(config('model_settings.settings_table_name')); |
|
26 | 3 | $table = Str::snake(trim($table)); |
|
27 | 3 | if (empty($table)) { |
|
28 | 3 | $this->error('The name of the table is required!'); |
|
29 | |||
30 | 3 | return false; |
|
31 | } |
||
32 | |||
33 | 3 | if (Schema::hasTable($table)) { |
|
34 | 3 | $this->error('Table "' . $table . '" already exists!'); |
|
35 | |||
36 | 3 | return false; |
|
37 | } |
||
38 | |||
39 | $fileName = date('Y_m_d_His') . '_create_' . $table . '_table.php'; |
||
40 | $path = database_path('migrations') . '/' . $fileName; |
||
41 | $className = 'Create' . ucfirst(Str::camel($table)) . 'Table'; |
||
42 | |||
43 | |||
44 | $stub = $file->get(__DIR__ . '/../../stubs/create_settings_table.stub'); |
||
45 | $stub = str_replace('DummyClass', $className, $stub); |
||
46 | $stub = str_replace('DummyTable', $table, $stub); |
||
47 | |||
48 | $file->put($path, $stub); |
||
49 | $this->line("<info>Created Migration:</info> {$fileName}"); |
||
50 | |||
51 | return true; |
||
52 | } |
||
54 |