From dba8a7cec8c1509db1186dbcc66875cb327fbf87 Mon Sep 17 00:00:00 2001 From: Jasper Tey Date: Fri, 22 Nov 2024 20:58:42 -0500 Subject: [PATCH] Handle laravel 10 side effect --- src/Commands/DomainControllerMakeCommand.php | 3 +++ tests/Generator/ControllerMakeTest.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Commands/DomainControllerMakeCommand.php b/src/Commands/DomainControllerMakeCommand.php index 2e50e0f..729d7c4 100644 --- a/src/Commands/DomainControllerMakeCommand.php +++ b/src/Commands/DomainControllerMakeCommand.php @@ -76,6 +76,9 @@ protected function buildClass($name) $replace["class {$controllerClass}".PHP_EOL] = "class {$controllerClass} extends Controller".PHP_EOL; } + // Remove Laravel 10 side effect + $replace["use {$this->getNamespace($name)}\Http\Controllers\Controller;".PHP_EOL] = ''; + $stub = str_replace( array_keys($replace), array_values($replace), diff --git a/tests/Generator/ControllerMakeTest.php b/tests/Generator/ControllerMakeTest.php index 1fb74cf..86f41e8 100644 --- a/tests/Generator/ControllerMakeTest.php +++ b/tests/Generator/ControllerMakeTest.php @@ -208,7 +208,7 @@ expect(file_exists($expectedPath))->toBeFalse(); // Remove the base controller - $baseControllerPath = base_path('app/Http/Controllers/Controller.php'); + $baseControllerPath = app_path('Http/Controllers/Controller.php'); if (file_exists($baseControllerPath)) { unlink($baseControllerPath);