1212use Honeybadger \HoneybadgerLaravel \Commands \HoneybadgerTestCommand ;
1313use Honeybadger \HoneybadgerLaravel \Contracts \Installer as InstallerContract ;
1414use Illuminate \Console \Scheduling \Event ;
15+ use Illuminate \Support \Facades \Blade ;
1516use Illuminate \Support \ServiceProvider ;
1617
1718class HoneybadgerServiceProvider extends ServiceProvider
@@ -28,10 +29,19 @@ public function boot()
2829
2930 $ this ->publishes ([
3031 __DIR__ .'/../config/honeybadger.php ' => base_path ('config/honeybadger.php ' ),
31- ], 'config ' );
32+ ], 'honeybadger-config ' );
33+ $ this ->publishes ([
34+ __DIR__ .'/../resources/views ' => resource_path ('views/vendor/honeybadger ' ),
35+ ], 'honeybadger-views ' );
36+ $ this ->publishes ([
37+ __DIR__ .'/../resources/lang ' => resource_path ('lang/vendor/honeybadger ' ),
38+ ], 'honeybadger-translations ' );
3239 }
3340
34- $ this ->registerMacros ();
41+ $ this ->registerEventHooks ();
42+ $ this ->loadViewsFrom (__DIR__ .'/../resources/views ' , 'honeybadger ' );
43+ $ this ->loadTranslationsFrom (__DIR__ .'/../resources/lang ' , 'honeybadger ' );
44+ $ this ->registerBladeDirectives ();
3545 }
3646
3747 /**
@@ -42,7 +52,7 @@ public function register()
4252 $ this ->mergeConfigFrom (__DIR__ .'/../config/honeybadger.php ' , 'honeybadger ' );
4353
4454 $ this ->app ->singleton (Reporter::class, function ($ app ) {
45- return ( new HoneybadgerLaravel )-> make ($ app ['config ' ]['honeybadger ' ]);
55+ return HoneybadgerLaravel:: make ($ app ['config ' ]['honeybadger ' ]);
4656 });
4757
4858 $ this ->app ->alias (Reporter::class, Honeybadger::class);
@@ -57,7 +67,7 @@ public function register()
5767 throw $ e ;
5868 };
5969
60- return ( new HoneybadgerLaravel )-> make ($ config );
70+ return HoneybadgerLaravel:: make ($ config );
6171 });
6272
6373 $ this ->app ->singleton ('honeybadger.isLumen ' , function () {
@@ -115,9 +125,9 @@ private function bindCommands()
115125 /**
116126 * @return void
117127 */
118- private function registerMacros ()
128+ private function registerEventHooks ()
119129 {
120- /** @param string|array|null $environments */
130+ /** @param string|array|null $environments */
121131 Event::macro ('thenPingHoneybadger ' , function (string $ id , $ environments = null ) {
122132 return $ this ->then (function () use ($ id , $ environments ) {
123133 if ($ environments === null || app ()->environment ($ environments )) {
@@ -126,7 +136,7 @@ private function registerMacros()
126136 });
127137 });
128138
129- /** @param string|array|null $environments */
139+ /** @param string|array|null $environments */
130140 Event::macro ('pingHoneybadgerOnSuccess ' , function (string $ id , $ environments = null ) {
131141 return $ this ->onSuccess (function () use ($ id , $ environments ) {
132142 if ($ environments === null || app ()->environment ($ environments )) {
@@ -135,4 +145,26 @@ private function registerMacros()
135145 });
136146 });
137147 }
148+
149+ private function registerBladeDirectives ()
150+ {
151+ // Views are not enabled on Lumen by default
152+ if (app ()->bound ('blade.compiler ' )) {
153+ Blade::directive ('honeybadgerError ' , function ($ options ) {
154+ if ($ options === '' ) {
155+ $ options = '[] ' ;
156+ }
157+
158+ $ defaults = "['class' => 'text-gray-500 text-sm', 'text' => 'Error ID:'] " ;
159+
160+ return "<?php echo \$__env->make('honeybadger::informer', $ options, $ defaults)->render(); ?> " ;
161+ });
162+
163+ Blade::directive ('honeybadgerFeedback ' , function () {
164+ $ action = rtrim (Honeybadger::API_URL , '/ ' ).'/feedback ' ;
165+
166+ return "<?php echo \$__env->make('honeybadger::feedback', ['action' => ' $ action'])->render(); ?> " ;
167+ });
168+ }
169+ }
138170}
0 commit comments