2424
2525namespace Pterodactyl \Providers ;
2626
27+ use View ;
28+ use Cache ;
2729use Pterodactyl \Models ;
2830use Pterodactyl \Observers ;
2931use Illuminate \Support \ServiceProvider ;
@@ -40,6 +42,9 @@ public function boot()
4042 Models \User::observe (Observers \UserObserver::class);
4143 Models \Server::observe (Observers \ServerObserver::class);
4244 Models \Subuser::observe (Observers \SubuserObserver::class);
45+
46+ View::share ('appVersion ' , $ this ->versionData ()['version ' ] ?? 'undefined ' );
47+ View::share ('appIsGit ' , $ this ->versionData ()['is_git ' ] ?? false );
4348 }
4449
4550 /**
@@ -57,4 +62,31 @@ public function register()
5762 $ this ->app ->register (\DaneEveritt \LoginNotifications \NotificationServiceProvider::class);
5863 }
5964 }
65+
66+ /**
67+ * Return version information for the footer.
68+ *
69+ * @return array
70+ */
71+ protected function versionData ()
72+ {
73+ return Cache::remember ('git-version ' , 5 , function () {
74+ if (file_exists (base_path ('.git/HEAD ' ))) {
75+ $ head = explode (' ' , file_get_contents (base_path ('.git/HEAD ' )));
76+ $ path = base_path ('.git/ ' . trim ($ head [1 ]));
77+ }
78+
79+ if (isset ($ path ) && file_exists ($ path )) {
80+ return [
81+ 'version ' => substr (file_get_contents ($ path ), 0 , 8 ),
82+ 'is_git ' => true ,
83+ ];
84+ }
85+
86+ return [
87+ 'version ' => config ('app.version ' ),
88+ 'is_git ' => false ,
89+ ];
90+ });
91+ }
6092}
0 commit comments