1 | <?php |
||
16 | class MigrationCommand extends Command |
||
17 | { |
||
18 | /** |
||
19 | * The console command name. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name = 'multilang:migration'; |
||
24 | |||
25 | /** |
||
26 | * The console command description. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $description = 'Creates a migration following the multilang specifications.'; |
||
31 | |||
32 | /** |
||
33 | * Execute the console command. |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public function handle() |
||
38 | { |
||
39 | $table = Config::get('multilang.db.texts_table'); |
||
40 | |||
41 | if ('' == $table) { |
||
42 | $this->error('Couldn\'t create migration.' . PHP_EOL . 'Table name can\'t be empty. Check your configuration.'); |
||
43 | |||
44 | return; |
||
45 | } |
||
46 | |||
47 | $this->line(''); |
||
48 | $this->info('Tables: ' . $table); |
||
49 | |||
50 | $message = 'A migration that creates "' . $table . '" tables will be created in database/migrations directory'; |
||
51 | |||
52 | $this->comment($message); |
||
53 | $this->line(''); |
||
54 | |||
55 | if ($this->confirm('Proceed with the migration creation? [Yes|no]', true)) { |
||
56 | $this->line(''); |
||
57 | |||
58 | $this->info('Creating migration...'); |
||
59 | if ($this->createMigration($table)) { |
||
60 | $this->info('Migration successfully created!'); |
||
61 | } else { |
||
62 | $this->error( |
||
63 | 'Couldn\'t create migration.' . PHP_EOL . ' Check the write permissions |
||
64 | within the database/migrations directory.' |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | $this->line(''); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Create the migration. |
||
74 | * |
||
75 | * @param string $table |
||
76 | * @return bool |
||
77 | */ |
||
78 | protected function createMigration($table) |
||
100 | } |
||
101 |