Completed
Push — 1.1 ( 4d5846...b85b4d )
by Quentin
12s
created

Setup::publishConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace A17\Twill\Commands;
4
5
use File;
6
use Illuminate\Console\Command;
7
8
class Setup extends Command
9
{
10
    protected $signature = 'twill:setup';
11
12
    protected $description = 'Setup Twill superadmin and publish configs';
13
14
    public function handle()
15
    {
16
        $this->publishMigrations();
17
        $this->call('migrate');
18
        $this->publishConfig();
19
        $this->createSuperAdmin();
20
    }
21
22
    private function publishMigrations()
23
    {
24
        $defaultMigrations = [
25
            '2014_10_12_000000_create_users_table.php',
26
            '2014_10_12_100000_create_password_resets_table.php',
27
        ];
28
29
        foreach ($defaultMigrations as $migration) {
30
            $fullPath = database_path('migrations/' . $migration);
31
            if (File::exists($fullPath)) {
32
                File::delete($fullPath);
33
            }
34
        }
35
36
        $this->call('vendor:publish', [
37
            '--provider' => 'A17\Twill\TwillServiceProvider',
38
            '--tag' => 'migrations',
39
        ]);
40
41
        $this->call('vendor:publish', [
42
            '--provider' => 'Spatie\Activitylog\ActivitylogServiceProvider',
43
            '--tag' => 'migrations',
44
        ]);
45
    }
46
47
    private function createSuperAdmin()
48
    {
49
        $this->call('twill:superadmin');
50
    }
51
52
    private function publishConfig()
53
    {
54
        $this->call('vendor:publish', [
55
            '--provider' => 'A17\Twill\TwillServiceProvider',
56
            '--tag' => 'config',
57
        ]);
58
59
        $this->call('vendor:publish', [
60
            '--provider' => "Dimsav\Translatable\TranslatableServiceProvider",
61
        ]);
62
    }
63
}
64