44
55use DebugBar \DataCollector \DataCollector ;
66use DebugBar \DataCollector \Renderable ;
7+ use Illuminate \Contracts \Foundation \Application as ApplicationContract ;
78use Illuminate \Foundation \Application ;
9+ use Illuminate \Support \Str ;
810
911class LaravelCollector extends DataCollector implements Renderable
1012{
11- /** @var \Illuminate\Foundation\Application $app */
12- protected $ app ;
13-
1413 /**
1514 * @param Application $app
1615 */
17- public function __construct (? Application $ app = null )
16+ public function __construct (protected ApplicationContract $ laravel )
1817 {
19- $ this ->app = $ app ;
2018 }
2119
2220 /**
2321 * {@inheritDoc}
2422 */
2523 public function collect ()
2624 {
27- // Fallback if not injected
28- $ app = $ this ->app ?: app ();
25+ return [
26+ "version " => Str::of ($ this ->laravel ->version ())->explode ('. ' )->first (),
27+ ];
28+ }
2929
30+ /**
31+ * {@inheritDoc}
32+ */
33+ public function gatherData ()
34+ {
3035 return [
31- "version " => $ app ::VERSION ,
32- "environment " => $ app ->environment (),
33- "locale " => $ app ->getLocale (),
36+ 'Laravel Version ' => $ this ->laravel ->version (),
37+ 'PHP Version ' => phpversion (),
38+ 'Environment ' => $ this ->laravel ->environment (),
39+ 'Debug Mode ' => config ('app.debug ' ) ? 'Enabled ' : 'Disabled ' ,
40+ 'URL ' => Str::of (config ('app.url ' ))->replace (['http:// ' , 'https:// ' ], '' ),
41+ 'Timezone ' => config ('app.timezone ' ),
42+ 'Locale ' => config ('app.locale ' ),
3443 ];
3544 }
3645
@@ -50,22 +59,10 @@ public function getWidgets()
5059 return [
5160 "version " => [
5261 "icon " => "laravel phpdebugbar-fab " ,
53- "tooltip " => " Laravel Version " ,
62+ "tooltip " => $ this -> gatherData () ,
5463 "map " => "laravel.version " ,
5564 "default " => ""
5665 ],
57- "environment " => [
58- "icon " => "desktop " ,
59- "tooltip " => "Environment " ,
60- "map " => "laravel.environment " ,
61- "default " => ""
62- ],
63- "locale " => [
64- "icon " => "flag " ,
65- "tooltip " => "Current locale " ,
66- "map " => "laravel.locale " ,
67- "default " => "" ,
68- ],
6966 ];
7067 }
7168}
0 commit comments