Skip to content

Commit

Permalink
Try replacing PHP_EOLs
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Nov 23, 2024
1 parent a611031 commit a6c184a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Commands/DomainControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ protected function buildClass($name)
$replace = [];

$appRootNamespace = $this->laravel->getNamespace();
$pathToAppBaseController = Path::normalize(app_path('Http/Controllers/Controller.php'));
$pathToAppBaseController = Path::normalize(app()->path('Http/Controllers/Controller.php'));

$baseControllerExists = $this->files->exists($pathToAppBaseController);

if ($baseControllerExists) {
$controllerClass = class_basename($name);
$fullyQualifiedBaseController = "{$appRootNamespace}Http\Controllers\Controller";
$namespaceLine = "namespace {$this->getNamespace($name)};";
$replace[$namespaceLine.PHP_EOL] = $namespaceLine.PHP_EOL.PHP_EOL."use {$fullyQualifiedBaseController};";
$replace["class {$controllerClass}".PHP_EOL] = "class {$controllerClass} extends Controller".PHP_EOL;
$replace["{$namespaceLine}\n"] = "{$namespaceLine}\n\nuse {$fullyQualifiedBaseController};";
$replace["class {$controllerClass}\n"] = "class {$controllerClass} extends Controller\n";
}

$stub = str_replace(
Expand Down

0 comments on commit a6c184a

Please sign in to comment.