1 | <?php |
||
11 | class InstallCommand extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The name and signature of the console command. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $signature = 'microboard:install'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'It\'s publish the package assets, and migrate the database.'; |
||
26 | |||
27 | /** |
||
28 | * @var Factory |
||
29 | */ |
||
30 | protected $microboard; |
||
31 | |||
32 | public function __construct(Factory $microboard) |
||
38 | |||
39 | /** |
||
40 | * Execute the console command. |
||
41 | * |
||
42 | * @return mixed |
||
43 | * @throws Exception |
||
44 | */ |
||
45 | public function handle() |
||
46 | { |
||
47 | $this->output->progressStart(4); |
||
48 | $this->output->newLine(); |
||
49 | |||
50 | $this->callSilent('storage:link'); |
||
51 | |||
52 | // Migrate the database |
||
53 | $this->callSilent('migrate'); |
||
54 | $this->info('Database tables have migrated'); |
||
55 | $this->output->progressAdvance(); |
||
56 | $this->output->newLine(); |
||
57 | |||
58 | // Publishes the assets |
||
59 | $this->publishesAssets(); |
||
60 | $this->output->progressAdvance(); |
||
61 | $this->output->newLine(); |
||
62 | |||
63 | // Create default roles and permissions |
||
64 | $admin = $this->createDefaultRolesAndPermissions(); |
||
65 | $this->output->progressAdvance(); |
||
66 | $this->output->newLine(); |
||
67 | |||
68 | // Create new admin |
||
69 | $this->askForCreatingNewAdmin($admin); |
||
70 | $this->output->progressAdvance(); |
||
71 | $this->output->newLine(); |
||
72 | |||
73 | $this->info('All done.'); |
||
74 | $this->info('Do something awesome!'); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * |
||
79 | */ |
||
80 | private function publishesAssets() |
||
98 | |||
99 | /** |
||
100 | * Create default roles and permissions |
||
101 | * |
||
102 | * @throws Exception |
||
103 | */ |
||
104 | private function createDefaultRolesAndPermissions() |
||
131 | |||
132 | /** |
||
133 | * ask for creating a new admin |
||
134 | * |
||
135 | * @param Role $role |
||
136 | * @return void |
||
137 | */ |
||
138 | private function askForCreatingNewAdmin(Role $role) |
||
175 | } |
||
176 |