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
|
|
|
|