1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OwenIt\Auditing\Console; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Str; |
6
|
|
|
use Illuminate\Console\Command; |
7
|
|
|
use Illuminate\Console\DetectsApplicationNamespace; |
8
|
|
|
|
9
|
|
|
class InstallCommand extends Command |
10
|
|
|
{ |
11
|
|
|
use DetectsApplicationNamespace; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* {@inheritdoc} |
15
|
|
|
*/ |
16
|
|
|
protected $signature = 'auditing:install'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
protected $description = 'Install all of the Auditing resources'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public function handle() |
27
|
|
|
{ |
28
|
|
|
$this->comment('Publishing Auditing Configuration...'); |
29
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'config']); |
30
|
|
|
|
31
|
|
|
$this->comment('Publishing Auditing Migrations...'); |
32
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'migrations']); |
33
|
|
|
|
34
|
|
|
$this->registerAuditingServiceProvider(); |
35
|
|
|
|
36
|
|
|
$this->info('Auditing installed successfully.'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Register the Auditing service provider in the application configuration file. |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
protected function registerAuditingServiceProvider() |
45
|
|
|
{ |
46
|
|
|
$namespace = str_replace_last('\\', '', $this->getAppNamespace()); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$appConfig = file_get_contents(config_path('app.php')); |
49
|
|
|
|
50
|
|
|
if (Str::contains($appConfig, 'OwenIt\\Auditing\\AuditingServiceProvider::class')) { |
51
|
|
|
return; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
file_put_contents(config_path('app.php'), str_replace( |
55
|
|
|
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL, |
56
|
|
|
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." OwenIt\Auditing\AuditingServiceProvider::class,".PHP_EOL, |
57
|
|
|
$appConfig |
58
|
|
|
)); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.