-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
001ea7e
commit a8b2a6b
Showing
4 changed files
with
91 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace OwenIt\Auditing\Console; | ||
|
||
use Illuminate\Support\Str; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Console\DetectsApplicationNamespace; | ||
|
||
class InstallCommand extends Command | ||
{ | ||
use DetectsApplicationNamespace; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $signature = 'auditing:install'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $description = 'Install all of the Auditing resources'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle() | ||
{ | ||
$this->comment('Publishing Auditing Configuration...'); | ||
$this->callSilent('vendor:publish', ['--tag' => 'config']); | ||
|
||
$this->comment('Publishing Auditing Migrations...'); | ||
$this->callSilent('vendor:publish', ['--tag' => 'migrations']); | ||
|
||
$this->registerAuditingServiceProvider(); | ||
|
||
$this->info('Auditing installed successfully.'); | ||
} | ||
|
||
/** | ||
* Register the Auditing service provider in the application configuration file. | ||
* | ||
* @return void | ||
*/ | ||
protected function registerAuditingServiceProvider() | ||
{ | ||
$namespace = str_replace_last('\\', '', $this->getAppNamespace()); | ||
|
||
$appConfig = file_get_contents(config_path('app.php')); | ||
|
||
if (Str::contains($appConfig, 'OwenIt\\Auditing\\AuditingServiceProvider::class')) { | ||
return; | ||
} | ||
|
||
file_put_contents(config_path('app.php'), str_replace( | ||
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL, | ||
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." OwenIt\Auditing\AuditingServiceProvider::class,".PHP_EOL, | ||
$appConfig | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters