1+ <?php
2+
3+ /*
4+ |--------------------------------------------------------------------------
5+ | Sandip Patel
6+ |--------------------------------------------------------------------------
7+ |
8+ | Date: 2017-09-18
9+ | Time: 11:28 AM
10+ */
11+ namespace PCB \Laravel ;
12+
13+ use Illuminate \Support \Facades \Route ;
14+ use Illuminate \Foundation \Support \Providers \RouteServiceProvider ;
15+
16+ class ServiceProvider extends RouteServiceProvider
17+ {
18+ /**
19+ * Bootstrap any application services.
20+ *
21+ * @return void
22+ */
23+ public function boot ()
24+ {
25+ $ this ->loadRoutesFrom (__DIR__ . '/routes.php ' );
26+ $ this ->loadMigrationsFrom (__DIR__ . '/migrations ' );
27+ $ this ->loadTranslationsFrom (__DIR__ .'/translations ' , 'modules ' );
28+
29+ $ this ->publishes ([
30+ __DIR__ . 'config.php ' => config_path ('modules.php ' ),
31+ __DIR__ .'/translations ' => resource_path ('lang/vendor/modules ' )
32+ ]);
33+
34+
35+ $ plugins = config ('plugins ' , []);
36+
37+ foreach ($ plugins as $ plugin => $ desc )
38+ {
39+ $ plugin_code = str_replace ('_ ' , '' , strtolower ($ plugin ));
40+ $ plugin_path = app_path (). '/Plugins/ ' .ucfirst ($ plugin_code ). DIRECTORY_SEPARATOR ;
41+ $ plugin_config = $ plugin_path . 'config.php ' ;
42+
43+ if ( \File::exists ($ plugin_config ) )
44+ {
45+ $ this ->mergeConfigFrom ($ plugin_config , $ plugin_code );
46+ $ this ->loadMigrationsFrom ($ plugin_path . 'Migrations ' );
47+ $ this ->loadViewsFrom ($ plugin_path .'Views ' , $ plugin_code );
48+ $ this ->loadTranslationsFrom ($ plugin_path .'Translations ' , $ plugin_code );
49+
50+ $ plugin_route = $ plugin_path . 'routes.php ' ;
51+ $ plugin_namespace = 'App\Plugins \\' .ucfirst ($ plugin_code ). '\\Controllers ' ;
52+
53+ if ( \File::exists ($ plugin_route ) )
54+ {
55+ Route::namespace ($ plugin_namespace )->group ($ plugin_path . 'routes.php ' );
56+ }
57+ }
58+ }
59+ }
60+ }
0 commit comments