@@ -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 runMigrations(): void
103111 }
104112 }
105113
106- public function registerPlugins (): void
114+ public function registerPlugins (string $ providerPath ): void
107115 {
108- $ providerPath = app_path ('Providers/Filament/AdminPanelProvider.php ' );
109-
110116 if (File::exists ($ providerPath )) {
111117 $ content = File::get ($ providerPath );
112118
@@ -152,8 +158,32 @@ 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. ' );
162+ }
163+ }
164+
165+ public function getPanelProviderPath (): string |array
166+ {
167+ $ providerPath = app_path ('Providers\Filament ' );
168+ $ providers = File::allFiles ($ providerPath );
169+ if (count ($ providers ) > 1 ) {
170+ $ providerNames = [];
171+ foreach ($ providers as $ provider ) {
172+ $ providerNames [] = $ provider ->getBasename ();
173+ }
174+ $ providerPath = multiselect (
175+ label: 'Which Panel should it be registered ' ,
176+ options: [...$ providerNames ],
177+ default: [$ providerNames [0 ]],
178+ );
179+
156180 }
181+ if (count ($ providers ) == 1 ) {
182+ $ providerPath .= '/ ' .$ providers [0 ]->getBasename ();
183+ }
184+
185+ return $ providerPath ;
186+
157187 }
158188
159189 public function finish (): void
0 commit comments