Completed
Pull Request — master (#1163)
by
unknown
03:47 queued 10s
created

MigrateFileToDatabaseCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputOption;
7
8
class MigrateFileToDatabaseCommand extends Command
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'module:migrate-to-database';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Migrate all modules to database management.';
23
24
    /**
25
     * Execute the console command.
26
     */
27
    public function handle(): int
28
    {
29
        if (!config('modules.database_management.enabled')) {
30
            $this->info('This feature only works when database management is on.');
31
32
            return false;
33
        }
34
        $this->laravel['modules']->migrateFileToDatabase($this->option('force'));
35
        $this->info('Migrated.');
36
37
        return 0;
38
    }
39
40
    /**
41
     * Get the console command options.
42
     *
43
     * @return array
44
     */
45
    protected function getOptions()
46
    {
47
        return [
48
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to update database.'],
49
        ];
50
    }
51
}
52