@@ -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,10 +158,35 @@ 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+
156163 }
157164 }
158165
166+ public function getPanelProviderPath (): string |array
167+ {
168+ $ providerPath = app_path ('Providers\Filament ' );
169+ $ providers = File::allFiles ($ providerPath );
170+ if (count ($ providers ) > 1 ) {
171+ $ providerNames = [];
172+ foreach ($ providers as $ provider ) {
173+ $ providerNames [] = $ provider ->getBasename ();
174+ }
175+ $ providerPath = multiselect (
176+ label: 'Which Panel should it be registered ' ,
177+ options: [...$ providerNames ],
178+ default: [$ providerNames [0 ]],
179+ );
180+
181+ }
182+ if (count ($ providers ) == 1 ) {
183+ $ providerPath .= '/ ' .$ providers [0 ]->getBasename ();
184+ }
185+
186+ return $ providerPath ;
187+
188+ }
189+
159190 public function finish (): void
160191 {
161192 note ('Moox Audit installed successfully. Enjoy! ' );
0 commit comments