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