diff --git a/config/modular.php b/config/modular.php index 69e005b..03fbf15 100644 --- a/config/modular.php +++ b/config/modular.php @@ -6,6 +6,13 @@ 'namespace' => 'Modules', 'vendor' => 'modular', 'directory_tree' => [ + 'app', + 'app/Console', + 'app/Console/Commands', + 'app/Http', + 'app/Http/Controllers', + 'app/Models', + 'app/Providers', 'bootstrap', 'bootstrap/cache', 'config', @@ -20,18 +27,6 @@ 'resources/js', 'resources/css', 'routes', - 'src', - 'src/Console', - 'src/Console/Commands', - 'src/Exceptions', - 'src/Facades', - 'src/Http', - 'src/Http/Controllers', - 'src/Models', - 'src/Policies', - 'src/Providers', - 'src/Support/Concerns', - 'src/Support/Contracts', 'storage', 'tests', ], diff --git a/src/Commands/ModuleMakeCommand.php b/src/Commands/ModuleMakeCommand.php index ffcf284..8d27e93 100644 --- a/src/Commands/ModuleMakeCommand.php +++ b/src/Commands/ModuleMakeCommand.php @@ -7,6 +7,7 @@ use Illuminate\Support\Str; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Savannabits\Modular\Facades\Modular; use Savannabits\Modular\Support\Concerns\CanManipulateFiles; use function Laravel\Prompts\text; @@ -86,7 +87,7 @@ private function generateModuleComposerFile(): void ], 'autoload' => [ 'psr-4' => [ - $this->moduleNamespace.'\\' => 'src/', + $this->moduleNamespace.'\\' => 'app/', $this->moduleNamespace.'\\Database\\Factories\\' => 'database/factories/', $this->moduleNamespace.'\\Database\\Seeders\\' => 'database/seeders/', ], @@ -123,7 +124,7 @@ private function generateModuleComposerFile(): void */ private function generateModuleServiceProvider(): void { - $path = $this->modulePath.'/src/'.$this->moduleStudlyName.'ServiceProvider.php'; + $path = Modular::module($this->moduleName)->appPath($this->moduleStudlyName.'ServiceProvider.php'); $namespace = $this->moduleNamespace; $class = $this->moduleStudlyName.'ServiceProvider'; $this->copyStubToApp('module.provider', $path, [ diff --git a/src/Module.php b/src/Module.php index 772e0bd..f324850 100644 --- a/src/Module.php +++ b/src/Module.php @@ -102,9 +102,17 @@ public function factoriesPath(string $path = '', bool $relative = false): string return $this->databasePath('factories'.DIRECTORY_SEPARATOR.trim($path, DIRECTORY_SEPARATOR), $relative); } + /** + * @deprecated Use appPath instead + */ public function srcPath(string $path = '', bool $relative = false): string { - return $this->path('src'.DIRECTORY_SEPARATOR.trim($path, DIRECTORY_SEPARATOR), $relative); + return $this->appPath($path, $relative); + } + + public function appPath(string $path = '', bool $relative = false): string + { + return $this->path('app'.DIRECTORY_SEPARATOR.trim($path, DIRECTORY_SEPARATOR), $relative); } public function resourcePath(string $string, bool $relative = false): string diff --git a/src/Support/Concerns/GeneratesModularFiles.php b/src/Support/Concerns/GeneratesModularFiles.php index c8f1e62..239904e 100644 --- a/src/Support/Concerns/GeneratesModularFiles.php +++ b/src/Support/Concerns/GeneratesModularFiles.php @@ -53,12 +53,12 @@ protected function getPath($name): string { $name = Str::replaceFirst($this->rootNamespace(), '', $name); - return $this->getModule()->srcPath(str_replace('\\', '/', $name).'.php'); + return $this->getModule()->appPath(str_replace('\\', '/', $name).'.php'); } protected function possibleModels() { - $modelPath = $this->getModule()->srcPath('Models'); + $modelPath = $this->getModule()->appPath('Models'); return collect(Finder::create()->files()->depth(0)->in($modelPath)) ->map(fn ($file) => $file->getBasename('.php'))