1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PavelMironchik\LaravelBackupPanel\Console; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use Illuminate\Console\DetectsApplicationNamespace; |
7
|
|
|
use Illuminate\Support\Str; |
8
|
|
|
|
9
|
|
|
class InstallCommand extends Command |
10
|
|
|
{ |
11
|
|
|
use DetectsApplicationNamespace; |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* The name and signature of the console command. |
15
|
|
|
* |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $signature = 'laravel-backup-panel:install'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* The console command description. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $description = 'Install all of the Laravel Backup Panel resources'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Create a new command instance. |
29
|
|
|
* |
30
|
|
|
* @return void |
31
|
|
|
*/ |
32
|
|
|
public function __construct() |
33
|
|
|
{ |
34
|
|
|
parent::__construct(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Execute the console command. |
39
|
|
|
* |
40
|
|
|
* @return mixed |
41
|
|
|
*/ |
42
|
|
|
public function handle() |
43
|
|
|
{ |
44
|
|
|
$this->comment('Publishing Laravel Backup Panel service provider...'); |
45
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'laravel-backup-panel-provider']); |
46
|
|
|
|
47
|
|
|
$this->comment('Publishing Laravel Backup Panel assets...'); |
48
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'laravel-backup-panel-assets']); |
49
|
|
|
|
50
|
|
|
$this->comment('Publishing Laravel Backup Panel configuration...'); |
51
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'laravel-backup-panel-config']); |
52
|
|
|
|
53
|
|
|
$this->registerServiceProvider(); |
54
|
|
|
|
55
|
|
|
$this->info('Laravel Backup Panel resources installed successfully.'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function registerServiceProvider() |
59
|
|
|
{ |
60
|
|
|
$namespace = Str::replaceLast('\\', '', $this->getAppNamespace()); |
61
|
|
|
|
62
|
|
|
$appConfig = file_get_contents(config_path('app.php')); |
63
|
|
|
|
64
|
|
|
if (Str::contains($appConfig, $namespace.'\\Providers\\LaravelBackupPanelServiceProvider::class')) { |
65
|
|
|
return; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
file_put_contents(config_path('app.php'), str_replace( |
69
|
|
|
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL, |
70
|
|
|
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." {$namespace}\Providers\LaravelBackupPanelServiceProvider::class,".PHP_EOL, |
71
|
|
|
$appConfig |
72
|
|
|
)); |
73
|
|
|
|
74
|
|
|
file_put_contents(app_path('Providers/LaravelBackupPanelServiceProvider.php'), str_replace( |
75
|
|
|
"namespace App\Providers;", |
76
|
|
|
"namespace {$namespace}\Providers;", |
77
|
|
|
file_get_contents(app_path('Providers/LaravelBackupPanelServiceProvider.php')) |
78
|
|
|
)); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
This trait has been deprecated. The supplier of the trait has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the trait will be removed and what other trait to use instead.