1515
1616class ForumServiceProvider extends ServiceProvider
1717{
18- /**
19- * The base directory for the package.
20- *
21- * @var string
22- */
23- const BASE_DIR = __DIR__ . '/../ ' ;
24-
2518 /**
2619 * Register the service provider.
2720 *
@@ -57,6 +50,16 @@ public function boot(Router $router, GateContract $gate)
5750 Carbon::setLocale ($ this ->app ->getLocale ());
5851 }
5952
53+ /**
54+ * Returns the package's base directory path.
55+ *
56+ * @return string
57+ */
58+ protected function baseDir ()
59+ {
60+ return __DIR__ . '/../ ' ;
61+ }
62+
6063 /**
6164 * Define files published by this package.
6265 *
@@ -65,19 +68,19 @@ public function boot(Router $router, GateContract $gate)
6568 protected function setPublishables ()
6669 {
6770 $ this ->publishes ([
68- static :: BASE_DIR . " config/api.php " => config_path ('forum.api.php ' ),
69- static :: BASE_DIR . " config/integration.php " => config_path ('forum.integration.php ' ),
70- static :: BASE_DIR . " config/preferences.php " => config_path ('forum.preferences.php ' ),
71- static :: BASE_DIR . " config/routing.php " => config_path ('forum.routing.php ' ),
72- static :: BASE_DIR . " config/validation.php " => config_path ('forum.validation.php ' )
71+ "{ $ this -> baseDir ()} config/api.php " => config_path ('forum.api.php ' ),
72+ "{ $ this -> baseDir ()} config/integration.php " => config_path ('forum.integration.php ' ),
73+ "{ $ this -> baseDir ()} config/preferences.php " => config_path ('forum.preferences.php ' ),
74+ "{ $ this -> baseDir ()} config/routing.php " => config_path ('forum.routing.php ' ),
75+ "{ $ this -> baseDir ()} config/validation.php " => config_path ('forum.validation.php ' )
7376 ], 'config ' );
7477
7578 $ this ->publishes ([
76- static :: BASE_DIR . " migrations/ " => base_path ('database/migrations ' )
79+ "{ $ this -> baseDir ()} migrations/ " => base_path ('database/migrations ' )
7780 ], 'migrations ' );
7881
7982 $ this ->publishes ([
80- static :: BASE_DIR . " translations/ " => base_path ('resources/lang/vendor/forum ' ),
83+ "{ $ this -> baseDir ()} translations/ " => base_path ('resources/lang/vendor/forum ' ),
8184 ], 'translations ' );
8285 }
8386
@@ -90,11 +93,11 @@ protected function loadStaticFiles()
9093 {
9194 // Merge config
9295 foreach (['api ' , 'integration ' , 'preferences ' , 'routing ' , 'validation ' ] as $ name ) {
93- $ this ->mergeConfigFrom (static :: BASE_DIR . " config/ {$ name }.php " , "forum. {$ name }" );
96+ $ this ->mergeConfigFrom ("{ $ this -> baseDir ()} config/ {$ name }.php " , "forum. {$ name }" );
9497 }
9598
9699 // Load translations
97- $ this ->loadTranslationsFrom (static :: BASE_DIR . " translations " , 'forum ' );
100+ $ this ->loadTranslationsFrom ("{ $ this -> baseDir ()} translations " , 'forum ' );
98101 }
99102
100103 /**
@@ -134,7 +137,7 @@ public function registerPolicies(GateContract $gate)
134137 */
135138 protected function loadRoutes (Router $ router )
136139 {
137- $ dir = self :: BASE_DIR ;
140+ $ dir = $ this -> baseDir () ;
138141 $ router ->group ([
139142 'namespace ' => 'Riari\Forum\Http\Controllers ' ,
140143 'as ' => config ('forum.routing.as ' ),
0 commit comments