ModelariumPublishCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Modelarium\Modelarium;
7
8
use function Safe\unlink;
9
10
class ModelariumPublishCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'modelarium:publish 
18
        {--vue : publish vue stubs for customization}
19
    ';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Publishes project files from Modelarium';
27
28
    /**
29
     * Create a new command instance.
30
     *
31
     * @return void
32
     */
33
    public function __construct()
34
    {
35
        parent::__construct();
36
    }
37
38
    /**
39
     * Execute the console command.
40
     *
41
     * @return mixed
42
     */
43
    public function handle()
44
    {
45
        $this->info("Removing original User code.");
46
        $f = base_path('app/User.php');
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        $f = /** @scrutinizer ignore-call */ base_path('app/User.php');
Loading history...
47
        if (file_exists($f)) {
48
            unlink($f);
49
        }
50
        $f = base_path('database/migrations/2014_10_12_000000_create_users_table.php');
51
        if (file_exists($f)) {
52
            unlink($f);
53
        }
54
55
        $this->call('vendor:publish', [
56
            '--provider' => "Modelarium\\Laravel\\ServiceProvider",
57
            '--tag' => "config"
58
        ]);
59
60
61
        foreach (Modelarium::getDirectiveLaravelLibraries() as $plugin) {
62
            $this->call('vendor:publish', [
63
                '--provider' => "$plugin\\Laravel\\ServiceProvider",
64
                '--tag' => "schema",
65
                '--force' => true
66
            ]);
67
    
68
            $this->call('vendor:publish', [
69
                '--provider' => "$plugin\\Laravel\\ServiceProvider",
70
                '--tag' => "schemabase",
71
            ]);
72
73
            if ($this->option('vue')) {
74
                $this->call('vendor:publish', [
75
                    '--provider' => "$plugin\\Laravel\\ServiceProvider",
76
                    '--tag' => "vue",
77
                    '--force' => true
78
                ]);
79
            }
80
        }
81
82
        $this->info("Setup done.");
83
    }
84
}
85