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

AdmineticWebsiteRollbackCommand::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 15
rs 9.9332
1
<?php
2
3
namespace Adminetic\Website\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\Artisan;
7
8
class AdmineticWebsiteRollbackCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'migrate:rollback: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 rollback 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:reset', [
46
                    '--path' => $path,
47
                    '--force' => $this->option('force'),
48
                ]);
49
            } else {
50
                $this->warn('No migrations found! Consider publish them first: <fg=green>php artisan vendor:publish --tag=website-migrations</>');
51
            }
52
        } else {
53
            $this->info('Please turn on publish_migrations option in config/website');
54
        }
55
    }
56
}
57