|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Uccello\Core\Console\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
|
6
|
|
|
use Illuminate\Support\Facades\Artisan; |
|
7
|
|
|
|
|
8
|
|
|
class InstallCommand extends Command |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The name and signature of the console command. |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $signature = 'uccello:install'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The console command description. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $description = 'Install Uccello'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* The views that need to be exported. |
|
26
|
|
|
* |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $views = [ |
|
30
|
|
|
'auth/login.stub' => 'auth/login.blade.php', |
|
31
|
|
|
'auth/register.stub' => 'auth/register.blade.php', |
|
32
|
|
|
'auth/passwords/email.stub' => 'auth/passwords/email.blade.php', |
|
33
|
|
|
'auth/passwords/reset.stub' => 'auth/passwords/reset.blade.php', |
|
34
|
|
|
'layouts/uccello.stub' => 'layouts/uccello.blade.php', |
|
35
|
|
|
// 'errors/403.stub' => 'errors/403.blade.php', |
|
36
|
|
|
// 'errors/404.stub' => 'errors/404.blade.php', |
|
37
|
|
|
// 'errors/500.stub' => 'errors/500.blade.php', |
|
38
|
|
|
]; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Create a new command instance. |
|
42
|
|
|
* |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct() |
|
46
|
|
|
{ |
|
47
|
|
|
parent::__construct(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Execute the console command. |
|
52
|
|
|
* |
|
53
|
|
|
* @return mixed |
|
54
|
|
|
*/ |
|
55
|
|
|
public function handle() |
|
56
|
|
|
{ |
|
57
|
|
|
// $this->comment('Publishing Uccello Service Provider...'); |
|
58
|
|
|
// $this->callSilent('vendor:publish', ['--tag' => 'uccello-provider']); |
|
59
|
|
|
|
|
60
|
|
|
$this->comment('Publishing Uccello Assets...'); |
|
61
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'uccello-assets']); |
|
62
|
|
|
|
|
63
|
|
|
$this->comment('Publishing Uccello Configuration...'); |
|
64
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'uccello-config']); |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
$this->comment('Copying User Model...'); |
|
68
|
|
|
copy( |
|
69
|
|
|
__DIR__.'/stubs/make/app/User.stub', |
|
70
|
|
|
app_path('User.php') |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
$this->comment('Copying Login Controller...'); |
|
74
|
|
|
copy( |
|
75
|
|
|
__DIR__.'/stubs/make/app/Http/Controllers/Auth/LoginController.stub', |
|
76
|
|
|
app_path('Http/Controllers/Auth/LoginController.php') |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
$this->comment('Copying Views...'); |
|
80
|
|
|
foreach ($this->views as $key => $value) { |
|
81
|
|
|
copy( |
|
82
|
|
|
__DIR__.'/stubs/make/views/'.$key, |
|
83
|
|
|
resource_path('views/'.$value) |
|
84
|
|
|
); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$this->comment('Executing make:auth...'); |
|
88
|
|
|
$this->callSilent('make:auth', ['--force' => true]); |
|
89
|
|
|
|
|
90
|
|
|
$this->registerJWT(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Publish JWT and generated JWT secret |
|
95
|
|
|
* |
|
96
|
|
|
* @return void |
|
97
|
|
|
*/ |
|
98
|
|
|
protected function registerJWT() |
|
99
|
|
|
{ |
|
100
|
|
|
$this->callSilent('vendor:publish', [ |
|
101
|
|
|
'--provider' => 'Tymon\JWTAuth\Providers\LaravelServiceProvider' |
|
102
|
|
|
]); |
|
103
|
|
|
|
|
104
|
|
|
// Generate JWT Secret if it does not exist yet (else there is an error) |
|
105
|
|
|
if (empty(env('JWT_SECRET'))) { |
|
106
|
|
|
$this->comment('Generating JWT Secret...'); |
|
107
|
|
|
$this->callSilent('jwt:secret'); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
} |