Passed
Push — main ( 81a08a...d746a9 )
by PRATIK
13:24
created

AdmineticWebsiteMigrateCommand::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 16
rs 9.9
1
<?php
2
3
namespace Adminetic\Website\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\Artisan;
7
8
class AdmineticWebsiteMigrateCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'migrate:adminetic-website  {--f|force : Force the operation to run when in production.}';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Command to migrate adminetic website module tables.';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return int
38
     */
39
    public function handle()
40
    {
41
        if (config('website.publish_migrations', true)) {
42
            $path = config('website.migration_publish_path', 'database/migrations/website');
43
44
            if (file_exists($path)) {
45
                $this->call('migrate', [
46
                    '--step' => true,
47
                    '--path' => $path,
48
                    '--force' => $this->option('force'),
49
                ]);
50
            } else {
51
                $this->warn('No migrations found! Consider publish them first: <fg=green>php artisan vendor:publish --tag=website-migrations</>');
52
            }
53
        } else {
54
            $this->info('Please turn on publish_migrations option in config/website');
55
        }
56
    }
57
}
58