Skip to content

Commit

Permalink
Merge pull request #129 from jetwes/main
Browse files Browse the repository at this point in the history
fixed #128 - check if l11 with new skeleton is used
  • Loading branch information
freekmurze authored Mar 20, 2024
2 parents f5f5951 + 889d592 commit f25a941
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,31 @@ protected function copyServiceProviderInApp(): self

$namespace = Str::replaceLast('\\', '', $this->laravel->getNamespace());

$appConfig = file_get_contents(config_path('app.php'));
if (intval(app()->version()) < 11 || !file_exists(base_path('bootstrap/providers.php'))) {
$appConfig = file_get_contents(config_path('app.php'));
} else {
$appConfig = file_get_contents(base_path('bootstrap/providers.php'));
}

$class = '\\Providers\\' . $providerName . '::class';

if (Str::contains($appConfig, $namespace . $class)) {
return $this;
}

file_put_contents(config_path('app.php'), str_replace(
"{$namespace}\\Providers\\BroadcastServiceProvider::class,",
"{$namespace}\\Providers\\BroadcastServiceProvider::class," . PHP_EOL . " {$namespace}{$class},",
$appConfig
));
if (intval(app()->version()) < 11 || !file_exists(base_path('bootstrap/providers.php'))) {
file_put_contents(config_path('app.php'), str_replace(
"{$namespace}\\Providers\\BroadcastServiceProvider::class,",
"{$namespace}\\Providers\\BroadcastServiceProvider::class," . PHP_EOL . " {$namespace}{$class},",
$appConfig
));
} else {
file_put_contents(base_path('bootstrap/providers.php'), str_replace(
"{$namespace}\\Providers\\AppServiceProvider::class,",
"{$namespace}\\Providers\\AppServiceProvider::class," . PHP_EOL . " {$namespace}{$class},",
$appConfig
));
}

file_put_contents(app_path('Providers/' . $providerName . '.php'), str_replace(
"namespace App\Providers;",
Expand Down

0 comments on commit f25a941

Please sign in to comment.