@@ -32,6 +32,8 @@ abstract class AddonServiceProvider extends ServiceProvider
3232 protected $ middlewareGroups = [];
3333 protected $ viewNamespace ;
3434 protected $ publishAfterInstall = true ;
35+ protected $ config = true ;
36+ protected $ translations = true ;
3537
3638 public function boot ()
3739 {
@@ -52,6 +54,8 @@ public function boot()
5254 ->bootStylesheets ()
5355 ->bootScripts ()
5456 ->bootPublishables ()
57+ ->bootConfig ()
58+ ->bootTranslations ()
5559 ->bootRoutes ()
5660 ->bootMiddleware ()
5761 ->bootViews ()
@@ -161,6 +165,44 @@ protected function bootScripts()
161165 return $ this ;
162166 }
163167
168+ protected function bootConfig ()
169+ {
170+ $ filename = $ this ->getAddon ()->slug ();
171+ $ directory = $ this ->getAddon ()->directory ();
172+ $ origin = "{$ directory }config/ {$ filename }.php " ;
173+
174+ if (! $ this ->config || ! file_exists ($ origin )) {
175+ return $ this ;
176+ }
177+
178+ $ this ->mergeConfigFrom ($ origin , $ filename );
179+
180+ $ this ->publishes ([
181+ $ origin => config_path ("{$ filename }.php " )
182+ ], "{$ filename }-config " );
183+
184+ return $ this ;
185+ }
186+
187+ protected function bootTranslations ()
188+ {
189+ $ slug = $ this ->getAddon ()->slug ();
190+ $ directory = $ this ->getAddon ()->directory ();
191+ $ origin = "{$ directory }resources/lang " ;
192+
193+ if (! $ this ->translations || ! file_exists ($ origin )) {
194+ return $ this ;
195+ }
196+
197+ $ this ->loadTranslationsFrom ($ origin , $ slug );
198+
199+ $ this ->publishes ([
200+ $ origin => resource_path ("lang/vendor/ {$ slug }" )
201+ ], "{$ slug }-translations " );
202+
203+ return $ this ;
204+ }
205+
164206 protected function bootPublishables ()
165207 {
166208 $ package = $ this ->getAddon ()->packageName ();
0 commit comments