Skip to content

Commit 6abc4db

Browse files
authored
Merge branch 'main' into hotfix-dynamic-module-paths
2 parents ccf7a45 + 1bf3aaa commit 6abc4db

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Commands/ModuleMakeFilamentWidgetCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public function handle(): int
107107

108108
if (! $panel) {
109109
$namespace = $module->appNamespace('Livewire');
110-
$path = $module->appPath((string) str($namespace)->after('App\\')->replace('\\', '/'));
110+
$prefix = str(config('modules.paths.app_folder', 'app'))->ltrim(DIRECTORY_SEPARATOR, '\\')->studly();
111+
$path = $module->appPath((string) str($namespace)->after("{$prefix}\\")->replace('\\', '/'));
111112
} elseif ($resource === null) {
112113
$widgetDirectories = collect($panel->getWidgetDirectories())->filter(fn ($dir) => str($dir)->contains($module->appPath()))->values()->all();
113114
$widgetNamespaces = collect($panel->getWidgetNamespaces())->filter(fn ($dir) => str($dir)->contains($module->appNamespace()))->values()->all();

src/ModulesPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ protected function getModulePanels(): array
103103
{
104104
// get a glob of all Filament panels
105105
$basePath = str(config('modules.paths.modules', 'Modules'));
106-
$pattern = $basePath . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Providers' . DIRECTORY_SEPARATOR . 'Filament' . DIRECTORY_SEPARATOR . '*.php';
106+
$appFolder = str(config('modules.paths.app_folder', 'app'));
107+
$pattern = $basePath . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $appFolder . DIRECTORY_SEPARATOR . 'Providers' . DIRECTORY_SEPARATOR . 'Filament' . DIRECTORY_SEPARATOR . '*.php';
107108
$panelPaths = glob($pattern);
108109

109110
$panelIds = collect($panelPaths)->map(fn ($path) => FilamentModules::convertPathToNamespace($path))->map(function ($class) {

src/ModulesServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,10 @@ protected function registerModuleMacros(): void
223223
Module::macro('appNamespace', function (string $relativeNamespace = '') {
224224
$prefix = str(config('modules.paths.app_folder', 'app'))->ltrim(DIRECTORY_SEPARATOR, '\\')->studly()->toString();
225225
$relativeNamespace = trim($relativeNamespace, '\\');
226-
if (strlen($prefix) > 0) {
226+
if (filled($prefix)) {
227227
$relativeNamespace = str_replace($prefix . '\\', '', $relativeNamespace);
228228
$relativeNamespace = str_replace($prefix, '', $relativeNamespace);
229229
}
230-
231230
return $this->namespace($relativeNamespace);
232231
});
233232
Module::macro('appPath', function (string $relativePath = '') {

0 commit comments

Comments
 (0)