diff --git a/src/Commands/ModuleMakeFilamentPageCommand.php b/src/Commands/ModuleMakeFilamentPageCommand.php index 29fe018b..d4724e77 100644 --- a/src/Commands/ModuleMakeFilamentPageCommand.php +++ b/src/Commands/ModuleMakeFilamentPageCommand.php @@ -37,7 +37,7 @@ public function handle(): int ->trim('/') ->trim('\\') ->trim(' ') - ->replace('/', '\\'); + ->replace(DIRECTORY_SEPARATOR, '\\'); $pageClass = (string) str($page)->afterLast('\\'); $pageNamespace = str($page)->contains('\\') ? (string) str($page)->beforeLast('\\') : @@ -86,7 +86,7 @@ public function handle(): int ->trim('/') ->trim('\\') ->trim(' ') - ->replace('/', '\\'); + ->replace(DIRECTORY_SEPARATOR, '\\'); if (! str($resource)->endsWith('Resource')) { $resource .= 'Resource'; @@ -229,17 +229,17 @@ public function handle(): int ->implode('.'))->prepend($module->getLowerName() . '::'); $path = (string) str($page) - ->prepend('/') + ->prepend(DIRECTORY_SEPARATOR) ->prepend(empty($resource) ? $path : $resourcePath . "\\{$resource}\\Pages\\") - ->replace('\\', '/') - ->replace('//', '/') + ->replace('\\', DIRECTORY_SEPARATOR) + ->replace('//', DIRECTORY_SEPARATOR) ->append('.php'); $viewPath = $module->resourcesPath( (string) str($view) ->replace($module->getLowerName() . '::', '') - ->replace('.', '/') - ->prepend('views/') + ->replace('.', DIRECTORY_SEPARATOR) + ->prepend('views' . DIRECTORY_SEPARATOR) ->append('.blade.php'), ); diff --git a/src/Modules.php b/src/Modules.php index 05544af4..19ed8b7c 100644 --- a/src/Modules.php +++ b/src/Modules.php @@ -19,7 +19,7 @@ public function getModule(string $name): \Nwidart\Modules\Module public function convertPathToNamespace(string $fullPath): string { $base = str(trim(config('modules.paths.modules', base_path('Modules')), '/\\')); - $relative = str($fullPath)->afterLast($base)->ltrim('/\\app'); + $relative = str($fullPath)->afterLast($base)->replaceFirst(DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR); return str($relative) ->ltrim('/\\') @@ -49,6 +49,6 @@ public function execCommand(string $command, ?Command $artisan = null): void public function packagePath(string $path = ''): string { //return the base path of this package - return dirname(__DIR__ . '../') . ($path ? DIRECTORY_SEPARATOR . trim($path, DIRECTORY_SEPARATOR) : ''); + return dirname(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . ($path ? DIRECTORY_SEPARATOR . trim($path, DIRECTORY_SEPARATOR) : ''); } } diff --git a/src/ModulesPlugin.php b/src/ModulesPlugin.php index 20a6e5ff..1d3d7b59 100644 --- a/src/ModulesPlugin.php +++ b/src/ModulesPlugin.php @@ -47,7 +47,7 @@ protected function getModulePlugins(): array } // get a glob of all Filament plugins $basePath = str(config('modules.paths.modules', 'Modules')); - $pattern = $basePath . '/*/app/Filament/*Plugin.php'; + $pattern = $basePath . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Filament' . DIRECTORY_SEPARATOR . '*Plugin.php'; $pluginPaths = glob($pattern); return collect($pluginPaths)->map(fn ($path) => FilamentModules::convertPathToNamespace($path))->toArray();