Skip to content

Commit e74d83e

Browse files
committed
Feature/command (#577)
1 parent a24d0a1 commit e74d83e

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/Commands/InstallCommand.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ public function handle()
3939
$this->publishConfiguration();
4040
// $this->publishMigrations();
4141
// $this->runMigrations();
42-
$this->registerPlugins();
42+
$providerPath = app_path('Providers\Filament');
43+
$panelsToregister = $this->getPanelProviderPath();
44+
if (count($panelsToregister) > 0 && $panelsToregister != null) {
45+
foreach ($panelsToregister as $panelprovider) {
46+
$this->registerPlugins($providerPath.'/'.$panelprovider);
47+
}
48+
} else {
49+
$this->registerPlugins($panelsToregister[0]);
50+
}
4351
$this->finish();
4452
}
4553

@@ -103,10 +111,8 @@ public function publishConfiguration(): void
103111
// }
104112
// }
105113

106-
public function registerPlugins(): void
114+
public function registerPlugins(string $providerPath): void
107115
{
108-
$providerPath = $this->getPanelProviderPath();
109-
110116
if (File::exists($providerPath)) {
111117
$content = File::get($providerPath);
112118

@@ -152,11 +158,11 @@ public function registerPlugins(): void
152158
File::put($providerPath, $newContent);
153159
}
154160
} else {
155-
alert('AdminPanelProvider not found. You need to add the plugins manually.');
161+
alert($providerPath.' not found. You need to add the plugins manually.');
156162
}
157163
}
158164

159-
public function getPanelProviderPath(): string
165+
public function getPanelProviderPath(): string|array
160166
{
161167
$providerPath = app_path('Providers\Filament');
162168
$providers = File::allFiles($providerPath);
@@ -165,10 +171,12 @@ public function getPanelProviderPath(): string
165171
foreach ($providers as $provider) {
166172
$providerNames[] = $provider->getBasename();
167173
}
168-
$providerPath .= '/'.$this->choice(
169-
'Which Panel should it be registered',
170-
[...$providerNames]
174+
$providerPath = multiselect(
175+
label: 'Which Panel should it be registered',
176+
options: [...$providerNames],
177+
default: [$providerNames[0]],
171178
);
179+
172180
}
173181
if (count($providers) == 1) {
174182
$providerPath .= '/'.$providers[0]->getBasename();

0 commit comments

Comments
 (0)